How to use
- Paste your SQL query (several queries separated by ; are fine).
- Choose your database so its special syntax is understood.
- Pick keyword case and indent, then click Format — or Minify for a single line.
- Click Copy to copy the result.
How it works
Formatting uses the open-source sql-formatter library: each clause (SELECT, FROM, WHERE, JOIN, GROUP BY…) starts on a new line and sub-queries are indented. Minify keeps strings and quoted names exactly as they are, removes comments and joins everything into one line.
Tips and common uses
Why format SQL at all
A query on one long line is hard to read, review and debug. When every clause starts on its own line and sub-queries are indented, you can see at a glance what is selected, joined and filtered. Code reviews and bug hunts get much faster.
Choose the right database first
Each database has its own syntax, and picking it avoids errors. MySQL and MariaDB use backticks around names, SQL Server (T-SQL) uses [square brackets] and TOP, PostgreSQL has :: casts and the ->> JSON operator, and Oracle (PL/SQL) has ROWNUM. If Standard SQL gives an error, try your own database.
Beautifier, prettifier and pretty print
These names all mean the same thing: changing only the layout of a query. Whatever you call it, the formatter never changes what the query does, only how it looks.
Uppercase keywords or not
Writing SELECT, FROM and WHERE in capitals makes the structure stand out from table and column names, and is the common convention. Lowercase is just as valid. Pick one style for your team and stay with it.
Watch words that are also keywords
Some words are reserved in one database but not in another. In Oracle mode, a column called name may be shown as NAME, because the word is a keyword there. Choose "Keep as typed" if you do not want any word changed.
PL/SQL, stored procedures and long scripts
The formatter works best on individual statements such as SELECT, INSERT, UPDATE and DELETE. The statements inside a BEGIN … END block are formatted, but the block itself is not indented, so check long procedures by eye.
When to minify
Minify turns the query into one line and removes comments. It suits queries that you place inside a code string, a config file or a log message. Keep a formatted copy for yourself, because the comments are gone after minifying.
Frequently asked questions
Does it run my query or connect to my database?
No. It only rearranges the text of the query in your browser. Nothing is executed or sent anywhere, so it is safe for queries that contain table names or data.
Why do I get an error?
The query uses syntax the chosen database doesn't understand, or has a typo such as a missing quote or bracket. Try choosing the right database, or check the line and column in the message.
Does it fix mistakes in my SQL?
No. It changes only the layout. A query that is wrong before formatting will still be wrong after it.
Can I format MySQL, PostgreSQL or SQL Server queries?
Yes. Choose MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle (PL/SQL), SQLite, BigQuery or Snowflake in the Database box, and the formatter understands that database's own syntax.
Is this a PostgreSQL formatter?
Yes. Choose PostgreSQL in the Database box and it understands :: casts, ->> and #>> JSON operators, RETURNING, ILIKE and dollar-quoted text. Pick MySQL, SQL Server (T-SQL), Oracle (PL/SQL) or SQLite the same way.
How do I beautify SQL in SQL Server?
Copy your T-SQL query from SQL Server Management Studio, choose "SQL Server (T-SQL)" here, click Format and paste the result back. It handles TOP, [square bracket] names, CROSS APPLY and temp tables.
What is the difference between format, beautify and prettify?
Nothing. They all mean the same thing: putting each clause on its own line and indenting sub-queries so the SQL is easy to read. The meaning of the query never changes.
Does it work as an Oracle PL/SQL code formatter?
It formats the SELECT, INSERT, UPDATE and DELETE statements in Oracle (PL/SQL) mode. The BEGIN … END block of a stored procedure is not indented, so check long procedures by eye.
Does formatting make a query faster or slower?
No. The database ignores spaces and line breaks, so the formatted and the one-line versions run in exactly the same way and take the same time.
Is there a size limit or a login?
There is no login and no fixed limit. The formatting happens on your device, so very large scripts depend on your browser and may take a moment.