SQL Formatter
Pretty-print SQL queries with keyword casing (UPPER, lower, or preserve), configurable indentation, and preserved string literals and comments. Works with most SQL dialects. Runs in your browser.
About SQL Formatter
Pretty-prints SQL with configurable keyword casing and indentation, while preserving string literals and comments. Validate JSON payloads before sending them to a query with theJSON Formatter.
Secure & Private Client-Side
This tool runs entirely in your browser. No data is sent to any server, ensuring your information remains private and secure.
About SQL Formatter
Pretty-print SQL queries with keyword casing (UPPER, lower, or preserve), configurable indentation, and preserved string literals and comments. Works with most SQL dialects. Runs in your browser.
Frequently Asked Questions
Which SQL dialects are supported? expand_more
The formatter handles ANSI SQL keywords common to PostgreSQL, MySQL, SQL Server, SQLite, and Oracle. Dialect-specific syntax may not format perfectly.
Are string literals and comments preserved? expand_more
Yes. Single-quoted strings, double-quoted identifiers, line comments, and block comments are detected and left untouched.
How are SELECT columns formatted? expand_more
Each column in a SELECT list is placed on its own line with one level of indentation, and commas sit at the end of each line.
Need to validate JSON before a query? expand_more
Use the [JSON Formatter](/tools/json-formatter/) to check your payload, then build your parameterized query here.
Is my SQL uploaded? expand_more
No. All formatting happens locally in your browser.
Common Use Cases
- Code Reviews: Reformat long ORM-generated SQL so teammates can review it.
- Debugging: Indent nested subqueries and joins to spot logic errors.
- Documentation: Pretty-print queries before embedding them in API docs.
- Migration Scripts: Standardize keyword casing across database migrations.