SQL Formatter
Format SQL queries with consistent indentation, keyword case and line breaks. Multi-dialect.
Quick answer: SQL Formatter: format SQL queries with consistent indentation, keyword case and line breaks. Multi-dialect. Runs entirely in your browser, free, no signup.
Last updated
Good to know
Consistent SQL formatting is more than aesthetics — a query with keywords aligned and clauses on their own lines is dramatically easier to review, and it produces cleaner version-control diffs so a reviewer sees the one predicate that changed rather than a reflowed wall of text. The formatter only rearranges whitespace and keyword case; it never alters the logic, so a formatted query returns exactly the same rows as the original.
Picking the right dialect matters for accuracy. Postgres, MySQL, T-SQL, BigQuery, and Snowflake each have keywords and functions the others don't (ILIKE, QUALIFY, MERGE, backtick quoting), and choosing the closest match lets the parser recognize them and lay them out correctly instead of treating them as bare identifiers. Feed it CTEs, window functions, and recursive queries and it will indent the nesting sensibly.
One prerequisite: the input needs to be syntactically valid. A missing comma or unclosed parenthesis can leave the formatter unable to indent gracefully, so if the output looks mangled, the real fix is usually a syntax error upstream rather than a formatter setting.
Formatting is a read-time convenience — it runs entirely in your browser, so even queries that touch sensitive schemas are safe to paste. When you need to compare two versions of a query or a result payload rather than reformat one, the JSON diff tool pairs well for the data side.
Frequently asked questions
- Will the formatter break my query?
- No — formatting only changes whitespace and keyword case. The semantics of the query are identical to the input. The exception: if you have syntax errors, the formatter may not be able to indent gracefully.
- Which dialects are supported?
- Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Snowflake, Redshift and T-SQL (SQL Server). Pick the closest match for the most accurate keyword recognition.
- Can I keep keywords lowercase?
- We default to UPPERCASE because it's the dominant convention; future versions will expose a toggle. For now, you can lowercase manually after formatting.
- Are my queries uploaded?
- No — formatting runs entirely in your browser. Nothing leaves your device.
- Will it format CTEs and window functions?
- Yes — common table expressions, window functions, recursive CTEs and stored procedures format cleanly.