SQL Formatter

Pretty-print messy or minified SQL with clean indentation — major clauses on their own lines, configurable indent width and keyword casing. Dialect-agnostic and forgiving. Runs entirely in your browser; nothing is uploaded.

Formatted SQL

About this tool

The SQL Formatter pretty-prints and standardizes a SQL query so it's easy to read, review and diff. Paste a one-line or minified query and it lays the statement out with each major clause — SELECT, FROM, WHERE, the JOINs, GROUP BY, ORDER BY, HAVING, LIMIT — on its own line, with select-list and column items one per line and AND / OR conditions broken onto indented continuation lines.

It is dialect-agnostic and forgiving: rather than parsing the query against one SQL grammar and rejecting anything unusual, it reformats the token stream, so it works on PostgreSQL, MySQL, SQLite, SQL Server and most other dialects. String literals, quoted identifiers and -- / /* … */ comments are preserved verbatim, and function calls such as COUNT(*) stay tight.

Options

Privacy

Everything runs locally in your browser via WebAssembly. Your query is never uploaded to a server.

FAQ

Will it tell me if my SQL has a syntax error?

No — by design. It reformats the token stream without parsing your query against a grammar, which is what lets it accept any dialect and never reject unusual syntax. An invalid query comes out nicely formatted but still invalid; validation is your database's job.

Does it work with PostgreSQL, MySQL, SQL Server…?

Yes — because it's dialect-agnostic. Instead of implementing one SQL grammar, it tokenizes and re-lays-out the statement, so PostgreSQL casts, MySQL backtick identifiers, SQL Server brackets, and SQLite quirks all pass through unchanged.

Will formatting alter my string literals, identifiers, or comments?

No. 'string literals' (including '' escapes), quoted identifiers, and both -- line and /* … */ block comments are preserved byte-for-byte. Only recognized SQL keywords are re-cased, and only if you chose upper or lower — table and column names are never touched.

Can it minify a query onto one line?

Not fully — setting Indent to 0 removes the indentation, but each major clause (SELECT, FROM, WHERE, …) still gets its own line. This tool is a pretty-printer; a dedicated minifier would be the reverse operation.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool sql-formatter "select id, name from users where age>18 order by name"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/sql-formatter/?sql=select%20id%2C%20name%20from%20users%20where%20age%3E18%20order%20by%20name&indent=2&keyword_case=upper

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.