Paste a query to format it for readability — formatting runs entirely in your browser, so your SQL is never uploaded.
How it works
- This is a rule-based formatter, not a full SQL parser — it handles common SELECT/INSERT/UPDATE/DELETE patterns well but may not perfectly format deeply nested subqueries.
- Leading commas put the comma at the start of each line rather than the end — a style many teams prefer because it makes it easy to comment out a column without breaking the syntax.
- The stats show how many tables and joins your query touches — a quick sanity check when reviewing someone else's SQL.
- Runs entirely in your browser; no query is ever executed or sent anywhere.
About the SQL formatter
This tool takes a SQL query written on one long line — or inconsistently indented — and lays it out with clear keywords, indentation and line breaks, so it's easy to read and review. Formatting doesn't change what the query does; it only changes how it looks.
Everything runs in your browser. Your query is never uploaded, which matters when it contains table names, column names or logic you'd rather not send to a third-party server.
Common uses
- Cleaning up a query copied from application logs or an ORM before reading it.
- Making a query readable for a code review or a pull request.
- Teaching or documenting SQL, where consistent layout makes the structure obvious.
- Spotting mistakes — a misplaced join or a stray comma is far easier to see once the query is formatted.
Use it carefully
Formatting is cosmetic: it will not fix a broken query, validate your syntax against a specific database, or protect against SQL injection. Always test a formatted query against your actual database before running it anywhere that matters, and never paste credentials or production data into any online tool.
Understanding your results
The formatted query keeps every keyword, table and value exactly as you wrote them — only the whitespace and line breaks change. Keywords are placed consistently and clauses are indented so the structure of the query is obvious at a glance.
Because nothing but layout changes, you can copy the result straight back into your code with confidence that it behaves identically to the original.
Does this run my query?
No. It only reformats the text. It never connects to a database or executes anything.
Which SQL dialect does it support?
It formats standard SQL keywords and works well for MySQL, PostgreSQL, SQL Server and SQLite. It doesn't validate dialect-specific syntax.
Is my query kept private?
Yes — formatting happens entirely in your browser and nothing is sent to a server.
SQL grew from relational database research
IBM researchers developed the relational database ideas that led to SEQUEL/SQL in the 1970s. SQL became a standard way to describe queries against relational data.
Formatting exposes query structure
Indenting SELECT columns, JOIN clauses and nested conditions does not change a valid query's intended logic, but it can make relationships and mistakes much easier for people to see.