Skip to content
hateitall

SQL Formatter

Turn a one-line query from a log or ORM into something you can read and review.

Processed locallyIn: SQLOut: SQL

Loading tool…

How to use sql formatter

  1. Paste SQL or open a .sql file.

  2. Pick the dialect so quotes and comments are read correctly.

  3. Choose UPPER, lower or as-typed keywords and the indent.

  4. Copy or download the formatted SQL.

What this tool does

  • Puts SELECT, FROM, WHERE, GROUP BY, ORDER BY and joins on their own lines, with AND and OR conditions underneath.
  • Indents subqueries, CTEs, CASE blocks and CREATE TABLE column lists.
  • Understands dialect quoting: backticks, [brackets], $$ dollar strings, E'' strings and # comments.
  • Keeps every comment.

How the result is verified

The formatted SQL is split into tokens again and compared with your input token for token; only whitespace and keyword case may differ.

Frequently asked questions

Can formatting break my query?

It only changes whitespace and keyword case, and the token-by-token check proves it for every run. Strings, names and comments are left exactly as written.

Why choose a dialect?

Databases quote differently. MySQL uses backticks and # comments, SQL Server uses [brackets] and PostgreSQL has $$ strings; the dialect tells the formatter which marks start text.

Is my data uploaded to a server?

No. Everything you drop, paste or type is processed by code running in this browser tab. You can check it yourself: open your browser's developer tools, watch the Network panel, and use the tool. No request carries your data.

SQL on one line, with comments removed or kept

SQL→ SQLLight on device

Batched INSERT statements from pasted CSV or JSON

CSV · JSON→ SQLLight on device

Beautify or minify JSON with your choice of indentation

JSON→ JSONLight on device

Pretty print or minify XML, checked by re-parsing

XML · SVG · RSS→ XMLLight on device