Skip to content
Language:en

SQL formatter

Beautify SQL queries with one clause per line and indented columns, or minify them to one line.

Action
Keywords
Indentation

Runs entirely in your browser. Your files never leave your device.

About this tool

Queries copied from logs, ORMs and old scripts are often squeezed onto one line, which makes a wrong join or a missing condition easy to miss. Paste the SQL and the formatter puts every clause on its own line, SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY, with the columns and the AND or OR conditions indented below, and subqueries indented one level deeper.

Keywords can be written in upper or lower case to match your team’s style, while table names, column names, quoted strings and comments are left exactly as they were. Minify does the opposite and packs a query onto a single line for a config file or a log search. It works with the common syntax shared by MySQL, PostgreSQL, SQLite and SQL Server.

How it works

  1. Paste one or more queries.
  2. Choose Format or Minify.
  3. Pick the keyword case and the indentation.
  4. Copy or download the result.

The formatter reads the query token by token and never executes it. Semicolons separate several statements with a blank line.

Worked example

A one-line query from a log, select u.id,u.name,count(o.id) from users u left join orders o on o.user_id=u.id where u.active=1 and o.created_at>'2026-01-01' group by u.id,u.name, comes out with each clause on its own line and both conditions indented under WHERE.

Laid out like this, the bug is visible: the condition on o.created_at in WHERE removes users without orders, silently turning the LEFT JOIN into an inner join. Moving it into the ON clause fixes it.

Good to know

  • Format before reviewing a query: misplaced conditions and missing join keys stand out.
  • Keep one style for keywords across a team; uppercase is the most common.
  • Strings and comments are left untouched, so formatting never changes what the query does.

Frequently asked questions

Does it check that my SQL is valid?
No, it only changes the layout. A query with a typo is formatted too; run it in your database to validate it.
Are my strings and comments changed?
Never. Quoted strings and identifiers keep their case and spaces; comments are kept when formatting and removed when minifying.
Is it safe to paste production queries?
Yes. Formatting happens in your browser; the query is not sent or stored anywhere.