SQL Formatter

Paste a SQL query to get a clean, readable version with major clauses on their own lines, sensible indentation and uppercased keywords. It runs in your browser, so your queries are never uploaded.

Paste a SQL query above to format it.

How SQL formatting works

A SQL formatter doesn't change what a query does — it changes how it looks. It tokenizes the statement, then puts each major clause on its own line, indents nested expressions, and standardizes the case of keywords. The result reads top-to-bottom in the order the database thinks about the query.

tokenize break on clauses (SELECT, FROM, WHERE…) indent & case

Major keywords like SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY and LIMIT start new lines; AND/OR inside a WHERE are indented under it; and the select list is laid out so each column is easy to scan.

Worked example

A cramped one-line query becomes:

SELECT id, name, email — the column list, comma-separated.
FROM users u JOIN orders o ON … — each on its own line.
WHEREANDORDER BYLIMIT 10 — clauses stacked and aligned.

What it does and doesn't do

This formatter is a readability tool: it reformats whitespace, line breaks and keyword case while leaving your logic, identifiers and string literals untouched. It works across common dialects (MySQL, PostgreSQL, SQL Server, SQLite) because it keys off standard keywords. It does not validate or execute your SQL, optimize it, or rename anything — it won't catch a syntax error, only make one easier to spot. Strings and quoted identifiers are preserved exactly so your data is never altered.

Tip: formatting JSON results from a query? Use the JSON formatter. Need to test a search pattern? Try the regex tester.

Frequently asked questions

Does formatting change what my query does?

No. A formatter only adjusts whitespace, line breaks and keyword case. Your tables, columns, conditions and string literals are preserved exactly, so the formatted query returns the same results as the original.

Which SQL dialects are supported?

It works with the common dialects — MySQL, PostgreSQL, SQL Server and SQLite — because it formats around standard keywords. Dialect-specific syntax still formats sensibly even if a keyword isn't in the highlight list.

Will it find errors in my SQL?

Not directly — it doesn't validate or run the query. But by laying out clauses cleanly it often makes a stray comma, missing keyword or unbalanced parenthesis much easier to see.

Is my query sent to a server?

No. Tokenizing and reformatting happen entirely in your browser, so your SQL — which can reveal schema and business logic — never leaves your device.

MB
Mustafa Bilgic · Editor, Calcool
A whitespace-and-case formatter that keys off standard SQL keywords; it never validates, executes or alters identifiers or string literals. Everything runs in your browser — nothing you enter is uploaded, logged or stored.

Related calculators