Skip to main content

SQL Formatter

Turn one-line SQL into clean, indented queries — supports MySQL, PostgreSQL, SQLite and more, with optional keyword casing.

What is a SQL formatter?

SQL copied out of code, a log or an ORM often arrives as one long, unreadable line. This SQL formatter lays it out with proper indentation and line breaks: SELECT, FROM, WHERE and JOIN each get their own section so you can see at a glance what the query does. It supports MySQL, PostgreSQL, SQLite and other dialects, and runs entirely locally in your browser.

How to use

  1. Paste your SQL into the input box.
  2. Choose the database dialect and keyword case.
  3. Click "Format" and copy the tidy result back into your code or tool.

Common use cases

  • Lay out a long query printed by an ORM or framework to debug it.
  • Standardize your team’s SQL style (indentation, uppercase keywords).
  • Working with JSON or other data too? Use the JSON formatter or JSON ⇄ CSV.

Why does picking the right "dialect" change the result?

SQL has an ANSI standard, but every database bolts on its own syntax sugar, so a formatter needs to know which dialect you're using to lay it out correctly. The classic example is identifier quoting: MySQL uses backticks `col`, while PostgreSQL and standard SQL use double quotes "col". Then there's LIMIT (MySQL/SQLite) vs TOP (SQL Server), PostgreSQL's :: type casts, BigQuery's backtick table names, and more. Pick the wrong dialect and the tool may treat these as plain strings or operators, so the indentation comes out odd. Before you paste, choose the database you actually use in the "Dialect" dropdown. One misconception worth clearing up: formatting is not validation, and it never runs your query — it only adjusts whitespace and indentation, so it won't tell you whether a table exists or whether the syntax runs on a real database. To clean the data itself, use the JSON formatter for JSON or JSON ⇄ CSV for tables.

Frequently Asked Questions

Which databases are supported?

It supports Standard SQL plus common dialects: MySQL, PostgreSQL, SQLite, MariaDB and BigQuery. Keywords and syntax differ slightly between dialects, so picking the right one gives more accurate formatting.

Does it change my query logic?

No. Formatting only adjusts whitespace, line breaks and indentation (plus optional keyword case). It never touches your tables, columns or conditions — the query does exactly the same thing.

Can it standardize keyword case?

Yes. You can preserve the original, force UPPERCASE (SELECT, FROM) or lowercase, so your team’s SQL style stays consistent.

Is my data uploaded?

No. Formatting happens locally in your browser; your SQL never leaves your device.

Related reading

Why Formatting SQL Matters (and What a Formatter Does) →

Embed this tool

Add this tool to your own website or blog for free — just copy and paste the code below (it includes a link back to this site).