SQL formatter

Make long SQL queries readable: every clause on its own line, joins and conditions indented, subqueries nested clearly and keywords in the case you prefer.

Free and private. Everything runs in your browser, nothing is uploaded.

How it works

  1. Paste your SQLPaste the code, type it or open a file. Try Sample to see an example.
  2. Check the resultThe result appears on the right as you type. Errors are shown with the line and column.
  3. Copy or downloadCopy the SQL with one click or download it as a file.

Built for everyday database work

Queries copied from logs, ORMs and stored procedures are often one long line. The formatter puts SELECT, FROM, WHERE and the rest on their own lines, lists selected columns one per line and lines up AND and OR conditions.

SQL Server brackets, MySQL backticks, PostgreSQL dollar quoted bodies, N'text' literals and GO separators are all recognized.

About SQL

SQL is the language of relational databases. The formatter puts each clause on its own line, indents joins, conditions and subqueries, and works with SQL Server, MySQL, PostgreSQL and SQLite syntax.

Frequently asked questions

Does it change my query?

Only whitespace and, if you choose, the case of keywords. Table names, column names and text values are never changed.

Is my code uploaded anywhere?

No. Formatting and minifying run in your browser. Your code is not sent to our servers.

Does minifying rename my variables?

No. Minifying removes comments, line breaks and spaces only. Names stay readable and the code behaves exactly the same, which makes it safe for any file.

Why are some line breaks kept in minified JavaScript?

JavaScript treats some line breaks as the end of a statement. Where removing one could change what the code does, it is kept.

Can I format JSON here?

JSON has its own tool with a tree view and validation. Use the JSON Tools page linked below.

Does it work offline?

Yes. After you open the page once, it keeps working without an internet connection.