SQL Formatter — Guide
Paste a messy SQL query and get it formatted — or minified to one line. Keywords upper-cased, clauses indented, one field per line. Supports PostgreSQL, MySQL, T-SQL, BigQuery and 8 more dialects, free in your browser.
What it is and when to use it
Paste a SQL query and get it formatted — keywords upper-cased, joins and clauses indented, one field per line — with dialect-aware parsing for PostgreSQL, MySQL, T-SQL, PL/SQL, SQLite, BigQuery, Redshift, Hive, Spark, MariaDB, DB2 and N1QL. A formatted query is the fastest way to review a 40-line join before running it.
Formats SQL that is crammed onto one line into a clearly indented structure — very useful for reading slow-query logs.
How to use it
- Paste the SQL
- Pick a dialect (optional)
- Copy the formatted result
A worked example
Fill in sample SQL
select id,name,created_at from users where status=1 order by created_at desc limit 10
Copy this into the tool, or open SQL Formatter
Questions people ask
- Why should I pick the right dialect?
- Dialects differ in keywords, quoting and comment syntax. Formatting with the engine you actually run keeps identifiers like backtick-quoted names or @variables recognised and placed correctly.
- Does formatting change how my query executes?
- No — whitespace and case are irrelevant to the SQL engine. Formatting is purely for humans; the query plan stays identical.
- Can it minify SQL back to one line?
- Prettifying is the core job. For a compact form, most developers keep the formatted version as the source of truth and let their tools strip whitespace on deploy.
- How do I make a slow-query log readable?
- Paste the whole one-line statement and let the formatter expand it — the JOIN structure and WHERE conditions become visible at a glance, which is usually where the slow part hides.
Next steps
Spotted something wrong on this page? Tell us via Contact Us