SQL Formatter

Paste a long or minified query and get clean, indented SQL with each clause on its own line. Pick your database dialect for accurate results.

✓ Runs locally in your browser — nothing is uploaded

In short: An SQL formatter rewrites a query with consistent line breaks, indentation and keyword case so it is easy to read and review, without changing what the query does.

About SQL Formatter

SQL copied from an ORM log, a BI tool or a colleague’s chat message often arrives as one long line. A formatter puts each clause — SELECT, FROM, JOIN, WHERE, GROUP BY — on its own line, indents sub-queries and lines up column lists, which makes joins and filters much easier to check.

This page uses the open-source sql-formatter library, which understands the syntax differences between dialects such as PostgreSQL :: casts, T-SQL square-bracket identifiers and BigQuery backtick table names. The query is formatted in your browser and never sent to a server, so it is safe to paste production queries.

How to use SQL Formatter

  1. Paste your SQL into the input box.
  2. Choose the database dialect, keyword case and indentation.
  3. Press Format SQL, then copy the result.

Examples

One-line query

select u.id,count(*) from users u join orders o on o.user_id=u.id group by u.id becomes a five-line query with SELECT, FROM, JOIN … ON and GROUP BY each starting a new line.

PostgreSQL casts

With the PostgreSQL dialect, created_at::date stays intact instead of being split around the colons.

Frequently asked questions

Does formatting change what my query does?

No. Only whitespace and, if you choose, keyword case change. Identifiers, string literals and comments are kept as they are.

Why do I get a parse error?

The formatter needs syntax it recognizes for the chosen dialect. Try the matching dialect, or check for an unclosed quote or bracket near the position shown.

Can it format several statements at once?

Yes. Separate statements with semicolons and each one is formatted, with a blank line between them.

Is my SQL uploaded?

No. Formatting runs locally in JavaScript; nothing you paste leaves your device. You can check this yourself: open your browser’s developer tools, switch to the Network tab and use the tool — no request carries your input.

Updated November 2026 · Free, no signup · How we build and test tools

Related tools All developer tools →