SQL formatter
Beautify SQL for MySQL, PostgreSQL, SQLite, SQL Server and more.
About the SQL Formatter tool
This SQL formatter rewrites a query with clear line breaks and indentation, so long SELECT, JOIN and WHERE clauses become easy to read and review. Pick one of 12 dialects (MySQL, MariaDB, PostgreSQL, SQLite, SQL Server T-SQL, Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark SQL, IBM Db2 or standard SQL) and whether keywords should be UPPERCASE, lowercase or kept as typed. Only spacing and letter case change, and the query is never run or sent to a server.
At a glance
- Dialects
- 12, including MySQL, PostgreSQL, SQLite, SQL Server, Oracle and BigQuery
- Keyword case
- UPPERCASE, lowercase or as typed
- Indent
- 2 spaces, 4 spaces or tabs; saved as query.sql
- Method
- sql-formatter library; the query is never run
- Price
- Free, no sign-up
- Works in
- Your browser, on phone or computer. Works offline after the first visit.
- Privacy
- What you type never leaves your device.
How to format a SQL query
- Paste your SQL or open a .sql file.
- Choose the SQL dialect, keyword case and indent.
- Copy or download the formatted query.
Private
Your text stays in your browser and is never sent to a server.
Instant
Results update as you type, with nothing to install.
Free
No sign-up, no limits and no ads inside your writing space.
SQL Formatter: frequently asked questions
Does formatting change what the query does?
No. Only spaces, line breaks and the letter case of keywords change. Table names, values and the order of everything stay the same.
Why does it say it cannot read my SQL?
The formatter could not parse part of the query, often a missing bracket or a dialect-specific feature. Check the line and column shown, or switch to the dialect your database uses (for example SQL Server for [brackets] and TOP).
Does it check my query against a database?
No. It only formats text. It never connects to a database, so it cannot tell you if a table or column exists.
Is my text sent anywhere?
No. Everything runs in your browser and your text never leaves your device. Nothing is stored on any server.



