SQL formatter

Turn a one-line query into something reviewable: clauses on their own lines, joins indented under them, keywords in capitals.

Indent
sql
Formattedsql
The result appears here

Questions

Which dialect does it understand?+

It reads tokens rather than parsing a grammar, so it works on Postgres, MySQL, SQLite and the rest alike. The trade is that it will not catch a syntax error for you.

Are my strings and comments safe?+

Yes. Quoted strings and -- comments are read whole and passed through untouched, so a comma inside a string never becomes a line break.

Why are only some keywords capitalised?+

Capitals mark the structure: clauses, joins and operators. Table and column names keep whatever case you wrote, because those are identifiers and on some servers the case matters.

Will it change what my query does?+

No. Only whitespace and the case of recognised keywords are touched, and neither changes the plan. Placeholders such as $1, ? or :name pass through as ordinary tokens, so a prepared statement stays prepared.

Related tools

The tools are free. So is most of the library.

1935 blocks and 989 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version