SQL Formatter
Pretty print SQL with uppercase keywords, smart indentation. Supports SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, INSERT, UPDATE, DELETE, CREATE. Minify, copy, download. Offline.
About this tool
Paste any SQL statement and get it pretty-printed with uppercase keywords, smart line breaks, and proper indentation. The formatter handles common clauses (SELECT/FROM/WHERE/JOIN/GROUP BY/ORDER BY/HAVING/LIMIT/UNION, INSERT/UPDATE/DELETE, CREATE/ALTER/DROP, plus BEGIN/COMMIT). The Minify button strips whitespace and comments to produce a single compact line. Output is syntax-highlighted by token type (keyword, function, string, number, comment). Copy the formatted result with one tap, or download it as a .sql file. Toggle UPPERCASE keywords on or off to match your team style. Works fully offline.
Details
- Category
- developer
- Version
- 1.0.0
- Size
- 16 KB
- Updated
- Jun 2026
Frequently Asked Questions
Which SQL dialects are supported?
The formatter is dialect-neutral — it works on standard SQL syntax that all major databases (PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, Oracle, SQL Server) accept. Vendor-specific extensions parse fine as long as the keywords are not in the reserved list. Function names like TO_CHAR, GETDATE, DATE_ADD are left as-is.
How does indentation work?
Each top-level keyword (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, ...) starts on a new line. The clauses that follow it are indented one level deeper. AND/OR conditions align with the WHERE keyword (not nested deeper). Commas after SELECT column lists or INSERT VALUES start a new indented line.
Does Minify remove comments?
Yes — both single-line (-- ...) and block (/* ... */) comments are removed. If you want to keep comments, format instead of minify.
Are my queries sent anywhere?
No. All tokenization and formatting happens locally in JavaScript. Your SQL is saved to localStorage so it persists when you reload, but is never uploaded.