SQL Formatter

Paste messy SQL and get it back cleanly indented - pick your dialect, indent size and keyword case, or minify it to one line.

Readable SQL in one paste

A query copied out of application logs or an ORM arrives as one long, unbroken line. This formatter reparses it and prints it with each clause on its own line and consistent indentation, so you can actually read the joins and the where conditions. It updates live as you type, so tweaking a query and re-formatting is instant.

Dialects, indenting and case

SQL is a family of dialects, not one language. Choosing MySQL, PostgreSQL, SQLite, T-SQL or BigQuery tells the parser which keywords and quoting rules apply, so backticks, double-quoted identifiers and dialect-only functions are handled properly rather than tripping it up. Set the indent to two or four spaces to match your codebase, and force keywords to upper or lower case - or preserve them exactly - with the keyword-case option.

Format or minify

Format is what you want most of the time. Minify does the reverse: it strips every run of whitespace outside quoted strings down to a single space, collapsing the whole statement onto one line. That is handy when you need to embed a query in a JSON payload, a log message or a single config field without newlines. String literals are left untouched, so the data your query carries never changes.

Handling the data around your queries too? The JSON formatter tidies API payloads, CSV to JSON turns exports into records to insert, and JSON to CSV does the reverse for reporting.

Frequently asked questions

Which SQL dialects are supported?
Standard SQL, MySQL, PostgreSQL, SQLite, T-SQL (Transact-SQL for SQL Server) and BigQuery. Picking the right one means dialect-specific keywords and quoting are handled correctly.
What does minify mode do?
It collapses all whitespace outside quoted strings into single spaces, giving you the query as one compact line. It is the opposite of formatting - useful for pasting a query into a log line, a JSON string or a one-line config value.
Can I control keyword case?
Yes. Choose Uppercase to force keywords like SELECT and FROM into capitals, Lowercase for the opposite, or Preserve to leave them exactly as you typed them.
Why does it say my SQL is invalid?
The formatter parses the query before pretty-printing it. If the syntax is broken - a stray bracket, an unterminated string - it cannot build the tree, so it shows a friendly error instead of mangling your query.
Is my query sent anywhere?
No. Formatting runs entirely in your browser. Nothing you paste is uploaded, so it is safe for queries that mention real table and column names.