Home › Developer Tools › SQL Formatter

SQL Formatter & Beautifier

Make long SQL queries readable: each clause on its own line, columns listed, joins and conditions indented.

Open a .sql file or paste below

How to use SQL Formatter

  1. Paste your SQL query or open a .sql file.
  2. Choose keyword case, indent and comma style, or minify.
  3. Copy the formatted SQL or download it.

Works with most databases

The formatter understands standard SQL plus common dialect features: MySQL backticks, SQL Server [brackets], PostgreSQL :: casts and $$ bodies, CTEs (WITH), window functions, CASE, UNION, INSERT, UPDATE, DELETE and CREATE TABLE. Strings and comments are never changed.

Readable SQL

  • One clause per line: SELECT, FROM, WHERE, GROUP BY, ORDER BY.
  • One column per line, so changes show up clearly in code reviews.
  • AND / OR conditions on their own lines.
  • Sub-queries indented inside their brackets.

Frequently asked questions

Does it check if my SQL is correct?

No. It formats the text; it doesn't run or validate the query against a database.

Will it change my query?

Only spacing, line breaks and (if you choose) keyword case. Values, names and strings are kept.

Can I format several statements?

Yes; separate them with semicolons.

Is my SQL uploaded?

No, everything happens in your browser.

Related tools

More Developer Tools