SQL Formatter — Beautify SQL Queries Online
Format and beautify SQL for PostgreSQL, MySQL, SQL Server, Oracle, BigQuery, Snowflake and 10 more dialects. Set keyword case and indentation; queries stay in your browser.
SQL
Formatted
Loading the formatter…
Formatted locally with sql-formatter. Your SQL is not uploaded.
How to use
- Paste a query or open a .sql file. Several statements separated by semicolons are formatted together.
- Choose your database dialect, keyword case and indentation. More options set function case, tabular alignment and where AND and OR break.
- Copy the result or download it as formatted.sql.
Example
select id, name from users where active = 1 order by name
Details and limitations
Formatting uses sql-formatter 15 in your browser. It changes whitespace and letter case only; it does not check that tables exist or run the query.
Inputs up to 512 KB are formatted. If a statement cannot be parsed, the line and column are shown; check that the dialect matches your database.
Your formatting settings are remembered in this browser.
FAQ
Does formatting change what my query does?
No. Only whitespace, line breaks and the case of keywords, data types and function names change. Identifiers, strings and comments are kept as written.
Why do I get a parse error?
Usually the dialect does not match the syntax, for example square-bracket identifiers outside SQL Server or backticks outside MySQL-style dialects. Choose the right dialect, or look for an unfinished statement near the reported line.
What is tabular indentation?
Tabular left and right pad clause keywords such as SELECT, FROM and WHERE to a fixed width, so the clauses line up in a column. Standard puts each clause body on its own indented lines.
Related tools
Format references
Tool page updated: