Runs 100% in your browser

The SQL formatter that actually reads your query

Paste any SQL — SELECT, CTEs, subqueries, window functions — and get clean, indented, readable output instantly. No login. No data uploaded. Works offline.

Postgres, MySQL, SQL Server, SQLite, BigQuery Nothing leaves your device Free forever
Input
Formatted output
Formatted SQL will appear here.
Ready. Paste a query above.

How the formatter works

This tool is a pure client-side SQL beautifier. Your query is tokenized inside your browser — keywords, identifiers, string literals, comments, and operators are identified, then reassembled with consistent indentation, aligned clauses, and line breaks at every major boundary (SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, UNION). CTEs, subqueries, and CASE expressions are indented recursively. Nothing is uploaded — the JavaScript that runs the formatter is the same code that renders this page.

Supported patterns

What it does not do

This is a formatter, not a validator or an execution planner. It doesn’t check whether your SQL is syntactically valid for a specific dialect, doesn’t rewrite queries for performance, and doesn’t evaluate expressions. If your query has a syntax error, the formatter tries to preserve the structure as-is rather than fail silently — but it can’t always guess intent. Vendor-specific procedural syntax (PL/pgSQL, T-SQL blocks) formats less cleanly than pure DML.

SQL, RAG, or backend roles hiring now

Companies vetted for engineering culture, autonomy, and manager quality — hiring across backend, data, and AI infrastructure.

Browse Engineering Jobs Or build a portfolio →

Frequently Asked Questions

How does this SQL formatter work?+
It runs entirely in your browser using vanilla JavaScript. Paste any SQL query and it identifies keywords, joins, subqueries, CTEs, and clauses, then reformats them with consistent indentation, uppercased keywords, and line breaks in the right places. Nothing is uploaded to a server — your queries never leave your machine.
Does the SQL formatter work with Postgres, MySQL, SQL Server, and SQLite?+
Yes. The formatter uses a dialect-agnostic approach that handles standard SQL syntax used across Postgres, MySQL, SQL Server, SQLite, BigQuery, Snowflake, and Redshift. It handles common vendor-specific keywords (LIMIT, TOP, OFFSET), CTEs, window functions, and JSON operators.
Is my SQL query sent to a server?+
No. The formatter is entirely client-side JavaScript. Nothing is uploaded, logged, or stored anywhere off your device. Safe to use for queries that include real table names, schemas, or business logic you don’t want to leak.
Can I customize the indentation and case?+
Yes. Choose 2 or 4 space indent (or tabs), and toggle keyword case (UPPERCASE, lowercase, PascalCase). Comma placement (leading or trailing) is also configurable. The formatter remembers your last-used settings via localStorage.
What SQL patterns does the formatter handle?+
SELECT / FROM / JOIN / WHERE / GROUP BY / HAVING / ORDER BY / LIMIT, CTEs (WITH ... AS), subqueries in SELECT/FROM/WHERE, UNION / INTERSECT / EXCEPT, CASE expressions, window functions (OVER, PARTITION BY), and INSERT/UPDATE/DELETE statements.
Why format SQL at all?+
Formatted SQL is drastically easier to review, debug, and share with teammates. A 60-line SELECT with 8 joins is hard to read as a wall of text but readable when properly indented. Code review comments become more precise. Diffs stay clean. And it forces you to look at the structure of your query rather than glossing over it.