SQL Formatter
Paste SQL on the left, get a formatted version on the right. Pick your dialect, tab width, and keyword case. Your queries never leave your browser.
How to use SQL Formatter
- 1
Paste or drop SQL
Paste a query into the left pane, or click Load file to open a .sql file from disk. Multiple queries separated by semicolons are supported.
- 2
Pick the dialect
Standard SQL is a safe default. Pick a specific dialect (PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, Redshift, SQL Server, Db2, Oracle PL/SQL, Spark, Trino, ClickHouse, DuckDB, MariaDB) to handle dialect-specific keywords and syntax correctly.
- 3
Configure style
Choose keyword case (UPPER, lower, or preserve) and indentation (2 spaces, 4 spaces, or tab). The output updates live as you change options.
- 4
Read the formatted output
The right pane shows the re-indented, re-wrapped SQL. Keywords align by clause, SELECT list items stack one per line for diffability.
- 5
Copy or download
Use the Copy button on the output pane to put the result on your clipboard, or click Download .sql to save it to a file.
Frequently asked questions
- Does this tool upload my SQL?
- No. Every parse, transform, and download runs entirely in your browser using JavaScript and Web Workers. The file never leaves your device — there is no upload endpoint and no server-side processing.
- Which dialects are supported?
- Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Snowflake, Redshift, SQL Server (T-SQL), IBM Db2, Oracle PL/SQL, Spark SQL, Trino / Presto, ClickHouse, and DuckDB. Picking the right dialect is only important when your query uses dialect-specific syntax — otherwise any of them will produce identical output.
- Does it change the semantics of my query?
- No. The formatter only rewrites whitespace, line breaks, and keyword casing. The tokens, their order, and the resulting query plan are identical to the input. Run an EXPLAIN before and after if you want to confirm.
- Why does my comment or blank line get moved?
- The formatter tokenises the SQL and re-emits it — trailing comments stay attached to their statement, but blank lines between statements are normalised to a fixed gap. If you need pixel-perfect comment preservation, format in your editor instead.
- Can it fix broken SQL?
- No. It reports a parse error (unexpected token, line and column) without attempting a fix. Repair the syntax first, then format.
Related tools
Generate SQL INSERT statements from a JSON array. Supports batched and per-row modes.
Format, minify, or validate JSON with configurable indentation and error reporting.
Format, validate, or canonicalize YAML with configurable indentation and line:column error reporting.