formatting
Popular
100% In-Browser Execution

SQL Formatter

Format messy SQL statements into clean, readable code with customizable indentation and keyword uppercase options. Supports Standard SQL, PostgreSQL, MySQL, SQLite, and Transact-SQL.

Dialect:
Indent:
Raw SQL Inputsql
8 lines•307 chars•307 B (307 bytes)
UTF-8 Encoded
Formatted SQL Outputsql
0 lines•0 chars•0 B (0 bytes)
UTF-8 Encoded
Quick Usage Guide & Examples(Click to toggle reference)
How to Use
  1. Paste your raw SQL query into the left editor panel.
  2. Select your preferred SQL dialect (Standard SQL, PostgreSQL, MySQL, SQLite, or T-SQL).
  3. Choose your indentation width (2 Spaces, 4 Spaces, or Tabs) and toggle UPPERCASE keywords if desired.
  4. Click 'Format SQL' to neatly structure SELECT clauses, JOIN statements, and WHERE conditions.
  5. Click 'Minify SQL' to strip comments and redundant whitespace for compact production strings.
  6. Copy the formatted output or download it as a .sql file.
Examples

Messy Multi-Table Query with Joins

Input
select u.id, o.total from users u inner join orders o on o.user_id = u.id where u.active = 1 and o.total > 100;
Output
SELECT u.id, o.total
FROM users u
INNER JOIN orders o
  ON o.user_id = u.id
WHERE u.active = 1
  AND o.total > 100;

Related Utilities

Discover other in-browser tools frequently used alongside this utility.

All tools