SQL Formatter & Beautifier
Turn a one-line SQL query into readable, consistently indented code. Pick your database dialect, keyword case and indentation, then copy the result.
How to format SQL
- Paste a query, or several separated by semicolons, into the left box.
- Choose your database dialect so dialect-specific syntax is recognized, then pick keyword case and indentation.
- Copy the formatted SQL from the right box.
Why consistent SQL formatting matters
Queries copied from logs, ORMs and BI tools usually arrive as one long line. Formatting puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) on its own line and indents conditions and column lists, so you can see the query's structure at a glance and spot problems like a missing join condition.
Teams that agree on a style (for example uppercase keywords and 2-space indents) get cleaner code reviews and diffs, because changes show up as real logic changes rather than whitespace noise. Paste two formatted versions into our diff checker to compare queries.
Formatting is done by the open-source sql-formatter library in your browser, and it only changes whitespace and keyword case, never the logic of your query. Queries containing customer data or credentials stay on your machine.
Need a different tool? Suggest it here — we read every message.
Frequently asked questions
Does formatting change what the query does?
No. Only whitespace, line breaks and keyword case change.
Which databases are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server, Oracle PL/SQL, SQLite, BigQuery, Snowflake and Redshift.
Why do I get a parse error?
The formatter needs syntactically valid SQL for the chosen dialect. Check for unbalanced quotes or parentheses, or try a different dialect.
Is my SQL sent anywhere?
No. It is formatted locally in your browser.