SQL Formatter
Paste SQL and it lays out each clause on its own line with indentation. Your input never leaves your browser.
How to use the SQL formatter
Compress to one line, or uppercase keywords, too. For SELECT, INSERT, UPDATE, DELETE, JOINs and subqueries. String and comment contents are preserved. Your SQL never leaves your browser.
New here? Press one of the "Examples (click to try)" chips above the input — a sample loads and the result shows right away. Then just paste SQL into the text area above. It formats live as you type. To collapse it to one line, switch to "Minify". Keyword uppercasing is a checkbox you can toggle.
Example: format a one-line query
Paste a cramped one-liner like this:
select id, name, email from users where age > 20 and status = 'active' order by nameIn "Format" mode it lays out by clause (uppercase keywords on):
SELECT
id,
name,
email
FROM users
WHERE age > 20
AND status = 'active'
ORDER BY
namePress "Minify" to collapse the extra line breaks and spaces back to one line.
- Format: breaks at clauses like SELECT/FROM/WHERE and indents columns and AND/OR. Subqueries are indented inside their parentheses.
- Minify: collapses line breaks and extra spaces into one line (strings and comments preserved).
- Uppercase keywords: uppercases only SQL keywords like SELECT, FROM, JOIN. Table and column names stay as written.
When it comes in handy
- Making a long one-line SQL from a log or ORM readable
- Normalizing the style of SQL across a team before review
- Seeing the nesting of JOINs and subqueries at a glance