SQL Formatter
Reformat a SQL query for readability, entirely in your browser, using the sql-formatter library.
This tool formats text only. It never connects to a database or runs your SQL.
Formatting SQL does not make a query safe to execute and does not prevent SQL injection.
How to use it
- Paste your SQL query into the input box
- Choose a dialect, the keyword case, and the indentation width
- Click Format SQL to get the reflowed query
- Copy the result, or Clear to reset the input and options
Pick a dialect — Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), BigQuery, Snowflake, or Oracle (PL/SQL) — then choose whether keywords are uppercased, lowercased, or left as written, and whether to indent with two or four spaces. The formatter only changes whitespace and keyword case: the contents of string literals, line and block comments, quoted, backtick, and bracket identifiers, and parameter placeholders such as ?, $1, :name, and @name are all preserved. Multiple statements separated by semicolons are kept in their original order. It is a formatter, not a validator or an optimizer, and it never connects to a database or runs your SQL. Formatting also does not make a query safe to execute or protect against SQL injection. Everything runs locally, so the query you paste is never uploaded or stored. This is separate from the JSON Formatter, which reflows JSON syntax rather than SQL.
FAQ
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), BigQuery, Snowflake, and Oracle (PL/SQL). Each one is mapped to the matching language in the underlying sql-formatter library.
No. The formatter only adjusts whitespace and keyword case. The text inside string literals, line comments, and block comments is left exactly as you wrote it.
No. It never runs a query or connects to a database. A query that the chosen dialect cannot parse produces a formatting error rather than a result; it is not a correctness check.
No. It changes layout only, never the query plan or the SQL itself beyond whitespace and keyword case. Query optimization and EXPLAIN analysis are out of scope.
No. Formatting happens entirely in your browser. Nothing is sent to a server, nothing is written to storage, and only an anonymous tool-usage event without your query is recorded.