What is a SQL formatter?
SQL copied out of code, a log or an ORM often arrives as one long, unreadable line. This SQL formatter lays it out with proper indentation and line breaks: SELECT, FROM, WHERE and JOIN each get their own section so you can see at a glance what the query does. It supports MySQL, PostgreSQL, SQLite and other dialects, and runs entirely locally in your browser.
How to use
- Paste your SQL into the input box.
- Choose the database dialect and keyword case.
- Click "Format" and copy the tidy result back into your code or tool.
Common use cases
- Lay out a long query printed by an ORM or framework to debug it.
- Standardize your team’s SQL style (indentation, uppercase keywords).
- Working with JSON or other data too? Use the JSON formatter or JSON ⇄ CSV.
Why does picking the right "dialect" change the result?
SQL has an ANSI standard, but every database bolts on its own syntax sugar, so a formatter needs to know which dialect you're using to lay it out correctly. The classic example is identifier quoting: MySQL uses backticks `col`, while PostgreSQL and standard SQL use double quotes "col". Then there's LIMIT (MySQL/SQLite) vs TOP (SQL Server), PostgreSQL's :: type casts, BigQuery's backtick table names, and more. Pick the wrong dialect and the tool may treat these as plain strings or operators, so the indentation comes out odd. Before you paste, choose the database you actually use in the "Dialect" dropdown. One misconception worth clearing up: formatting is not validation, and it never runs your query — it only adjusts whitespace and indentation, so it won't tell you whether a table exists or whether the syntax runs on a real database. To clean the data itself, use the JSON formatter for JSON or JSON ⇄ CSV for tables.