What is the SQL Formatter?
Queries copied from logs, ORMs and old code often arrive as one endless line. Paste them here and get clean SQL with each clause on its own line, joins and conditions indented and keywords in the case you like.
Pick your database so its own syntax is understood: MySQL and MariaDB backticks, PostgreSQL casts and dollar quotes, SQL Server brackets, Oracle PL/SQL, BigQuery and Snowflake. Minify does the opposite and squeezes a query into one line, keeping text inside quotes exactly as it was and removing comments.
Features
9 dialects
MySQL, MariaDB, PostgreSQL, SQL Server, SQLite, Oracle, BigQuery, Snowflake and standard SQL.
Keyword case
UPPER, lower or as you typed it.
Indent
2 spaces, 4 spaces or tabs.
Minify
One line, comments removed, strings untouched.
One-click copy
Copy the result straight into your editor.
Private
Queries never leave your browser.
How to use the SQL Formatter
- 1
Paste your SQL.
- 2
Pick the database, keyword case and indent.
- 3
Press Format SQL, or Minify, and copy the result.
Who it is for
Debugging slow queries
Read a long query from the slow log.
Code reviews
Format SQL before you commit it.
Documentation
Paste tidy queries into wikis and tickets.
Tips for better results
- If formatting fails, check the database choice: each dialect allows different quotes and keywords.
- Several queries separated by semicolons are formatted one after another with a blank line between them.
Your privacy: it stays on your device
- This tool runs entirely in your browser. What you type and the files you choose are processed on your own device and are never sent to our server.
- Nothing is uploaded, stored or kept in a history, so it is safe for private text, documents, photos and keys.
- It keeps working on a slow connection, because no answer has to come back from a server.
Questions people ask
Is my SQL sent to your server?
No. It is formatted by a script in your browser, so table names and data in the query stay private.
Does formatting change what the query does?
No. Only spaces, line breaks and keyword case change; names, values and strings stay exactly the same.