SQL Formatter

Paste a single-line SQL query and format it with readable indentation.

What it's for

SQL queries generated by ORMs, exported from logs, or copied from somewhere often come as a single hard-to-read line. This tool reorganizes the query with line breaks and indentation around its clauses (SELECT, FROM, WHERE, JOIN, ORDER BY, etc.), making it easier to read and review.

How it works

Uses the open-source sql-formatter library, which supports common variations of standard SQL syntax. Nothing is sent to a server: formatting happens entirely in your browser.

Before and after

The query select id,name from customers c join orders o on o.customer_id=c.id where o.total>100 order by name is spread over lines, with SELECT, FROM, JOIN, WHERE and ORDER BY each in its own block and columns listed one per line. Subqueries get an extra level of indentation.

Limits worth knowing

Formatting never changes what a query means, but it does not validate it either: a misspelled column name goes unnoticed. Placeholders such as ? or :id are preserved, and comments stay in place. For stored procedures and vendor-specific blocks, the result may need manual touch-ups.

Frequently asked questions

Does it work with any SQL dialect (MySQL, PostgreSQL, etc.)?

The tool uses the standard SQL formatter, which covers the syntax common across major databases well — very dialect-specific cases may not format perfectly.

Is my data/queries sent to any server?

No — formatting happens locally in your browser.

Will keywords be converted to uppercase?

The goal is line breaks and indentation; keyword casing depends on the formatter's configuration and may vary. String literals and table or column names are never altered.

Can I format several statements at once?

Yes. Statements separated by semicolons are formatted in sequence, each in its own block, which makes it easy to review an entire migration script pasted in one go.