SQL Formatter
Reformat a SQL statement into a consistent, readable layout — keywords uppercased, each clause on its own line, subqueries and conditions indented to show their structure. Supports 8 dialects (Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, BigQuery, Oracle) using the sql-formatter library, so dialect-specific syntax parses correctly. Paste directly or upload a .sql file. Runs entirely client-side — nothing is uploaded.
About this tool
This tool reformats a SQL statement into a consistent, readable layout — keywords uppercased, clauses (SELECT, FROM, WHERE, JOIN) each starting their own line, and nested subqueries and conditions indented to show their structure. Dialect matters because SQL isn't fully standardized across databases: SQL Server's TOP, BigQuery's backtick-quoted identifiers, and Oracle's PL/SQL blocks all parse differently, so picking the right one avoids the formatter misreading dialect-specific syntax as an error. It runs entirely client-side using the sql-formatter library, a widely-used SQL parser and formatter — nothing you paste or upload is ever sent anywhere.
What you can do
- Format SQL into readable, consistently-indented statements
- 8 dialects — Standard SQL, MySQL, PostgreSQL, SQLite, T-SQL, BigQuery, and more
- Paste directly, or upload a .sql file
- Nothing is uploaded — formatting happens locally in your browser
How to use
Step 1
Add your SQL
Paste it directly, or upload a .sql file.
Step 2
Pick a dialect
Dialect affects keyword recognition and dialect-specific syntax like SQL Server's TOP or BigQuery's backtick-quoted identifiers.
Step 3
Copy the result
Formatted, consistently-indented SQL, ready to paste back into your codebase.
Example
This SQL:
Input
select a,b from t where x=1 and y=2
Formatted
SELECT a, b FROM t WHERE x = 1 AND y = 2
formats to that — each clause on its own line, with AND conditions indented under WHERE to show they belong to the same clause.
How your data is handled
This tool is labeled 🟢 Browser: your SQL is formatted directly in your browser using the sql-formatter library — nothing is uploaded to a server, and nothing about it is retained once you leave the page.
Frequently asked questions
Why does it matter which dialect I pick?+
Different databases have their own keywords and syntax extensions — SQL Server's TOP, BigQuery's backtick-quoted identifiers, Oracle's PL/SQL blocks. Picking the dialect that matches your database avoids the formatter misinterpreting valid, dialect-specific syntax as a syntax error.
Does it change what my query does?+
No — only whitespace, line breaks, and keyword casing change. The query's logic, clause order, and every literal value are preserved exactly.
Why did it say my SQL has a syntax error?+
Usually a genuine issue — unbalanced parentheses, a missing closing quote, or a keyword that doesn't exist in the dialect you picked. Try Standard SQL if you're unsure which dialect your query targets.
Can I upload a .sql file instead of pasting?+
Yes — the file picker next to the input box accepts a .sql or .txt file directly.
Is my SQL uploaded anywhere?+
No — whether pasted or loaded from a file, formatting happens directly in your browser using the sql-formatter library. Nothing here ever leaves your device.