About SQL Formatter
SQL Formatter takes cramped or inconsistently indented SQL and rewrites it with clean, predictable indentation — one clause per line, aligned keywords, readable joins and subqueries. It also catches structural breaks like unbalanced parentheses or unterminated strings, and can minify a query back down to a single line. Everything runs in your browser — nothing you paste is uploaded, logged, or stored anywhere.
How to use it
- 1
Paste your SQL
Paste a query into the input pane on the left, or drag a .sql file directly onto it.
- 2
Choose an action
Click Format to pretty-print with standard indentation, Minify to collapse it to one line, or Validate to check for structural errors without changing anything.
- 3
Copy the result
Click Copy to copy the output pane to your clipboard, or Clear to start over.
What it does
- Pretty-prints SQL with consistent indentation and uppercase keywords
- Minifies SQL by collapsing whitespace and stripping comments, without touching string or identifier contents
- Flags structural errors — unbalanced parentheses, unterminated quotes — with the exact line and column
- Works across standard SQL syntax: SELECT, JOIN, subqueries, CTEs, INSERT/UPDATE/DELETE, and DDL statements
FAQ
Which SQL dialect does this support?
It formats using standard ANSI SQL conventions, which reads cleanly for MySQL, PostgreSQL, SQLite, SQL Server, and most other dialects. It doesn't do dialect-specific validation (e.g. Postgres-only syntax vs. T-SQL-only syntax), only structural checks that apply universally.
Why doesn't Validate catch every mistake in my query?
Validate checks structure — matching parentheses, closed string literals — not whether your query would actually run against a database. It can't know your schema, so it won't catch a misspelled column name or a table that doesn't exist. Catching those requires running the query against a real database.
Does Minify change what my query does?
No. Minify only collapses whitespace and strips comments outside of string and identifier literals — the query's logic and any string values are left byte-for-byte intact.
Does this tool send my query anywhere?
No. Formatting, minifying, and validating all happen locally in your browser. Your SQL — including any embedded credentials or data in literals — is never sent over the network.