Converters & Dev

SQL Formatter

Paste a query that arrived as one long line and get it back indented, with the keywords lined up. Works with MySQL, PostgreSQL, SQLite, SQL Server, BigQuery and others.

Your query

Formatted SQL

Lines
—
Characters
—

Why formatting a query matters

A query copied out of a log or an ORM arrives as one enormous line. Formatted, the same query shows its shape at a glance: what is selected, what it joins, where it filters. Most of the time, finding the bug in a slow or wrong query starts with being able to read it.

What the formatter does

How to use the SQL formatter

  1. Paste the query — one statement or a whole script.
  2. Pick your dialect so that quoting and dialect-only keywords are handled properly.
  3. Copy the result back into your editor, or tick minify to collapse it into one line.

Reading a formatted query

Privacy

Queries often contain table names, column names and real values. Everything here runs in your browser — the query is never sent to a server, and nothing is logged.

Frequently asked questions

How do I format a SQL query online?

Paste it above and it is formatted as you type. Choose your database dialect so that quoting and dialect-specific keywords are treated correctly.

Does formatting change what the query does?

No. Only whitespace and the case of keywords change. String values, comments and identifiers are left exactly as they were.

Can I put the query back on one line?

Yes — tick "minify instead". Comments are stripped and the whitespace collapsed, which is what you want for a config value or a command line.