Format SQL Queries for Readability and Debugging
Format and prettify SQL queries in your browser. Supports SELECT, INSERT, UPDATE, CREATE. Private, no upload, no signup.
The problem
You get a SQL query from a Slack message, a log file, or a legacy codebase, and it's one long unbroken line. SELECT a.id, a.name, b.total FROM accounts a JOIN orders b ON a.id = b.account_id WHERE b.status = 'active' AND b.created > '2026-01-01' ORDER BY b.total DESC LIMIT 50. Good luck reading that in a code review.
Readable SQL has one clause per line, consistent indentation, and uppercase keywords. Formatting by hand is tedious. IDE plugins require installing extensions. Online formatters upload your queries to a server — fine for sample data, risky for production queries with real table names and business logic.
How it works
- Paste your SQL into the input panel — any dialect, any size.
- See it formatted instantly — major clauses on new lines, keywords uppercased, joins indented, subqueries nested.
- Adjust the style — choose 2-space, 4-space, or tab indentation. Toggle keyword casing. Select your dialect (Standard, MySQL, PostgreSQL) for dialect-specific keywords.
- Minify if needed — collapse the query back to a single line for embedding in code or config.
- Copy the result — one click to clipboard.
Your data never leaves your browser. All processing happens locally.
Why I built it
I read and write SQL daily — debugging queries, reviewing pull requests, digging through logs. Unformatted SQL is the norm in production systems, and reformatting it by hand gets old fast. I wanted something instant that I could keep in a tab — paste, read, done. No extensions to install, no server involved.
Tips and reference
Common SQL formatting conventions that make queries easier to read and review:
| Convention | Example | Why |
|---|---|---|
| Uppercase keywords | SELECT, FROM, WHERE | Visually separates SQL syntax from your data |
| One clause per line | SELECT ... | Each clause is scannable independently |
| Indent joins | JOIN orders ON ... | Shows table relationships at a glance |
| Indent AND/OR | AND status = 'active' | WHERE conditions are readable as a list |
| Trailing commas in SELECT | a.id, | Easy to add/remove columns, clean diffs |
Note: This tool formats SQL — it doesn't validate it. If your query has a syntax error, the formatter will still indent it. The formatting just makes the error easier to spot.
Built with vanilla HTML/JS. No frameworks, no backend, loads instantly.