Skip to content
Categories
SQL Formatter
Format SQL into a readable, well-indented layout.
Overview
- Formats hard-to-read single-line SQL, or SQL with inconsistent indentation, by uppercasing keywords and applying readable line breaks and indentation.
- Supports major SQL statements such as SELECT, INSERT, UPDATE, and DELETE, and can also format queries with complex JOINs or subqueries.
- Useful when you want to share SQL in a human-readable form during code review or while writing documentation.
Usage
- Enter the SQL you want to format into the text area.
- Click the "Format" button.
- The result is displayed with keywords uppercased and readable line breaks and indentation.
Example
Input
select id, name from users where age > 18 order by name
Output
SELECT id, name FROM users WHERE age > 18 ORDER BY name
Use Cases
- Formatting a single-line SQL query output by logs or a tool into a readable form for review
- Unifying the indentation of SQL you wrote yourself to match your team's coding conventions
- Formatting a query with complex JOINs or subqueries to make its structure easier to grasp
FAQ
Which SQL dialects are supported?
Standard SQL syntax is supported (using the sql-formatter library). Dialect-specific syntax may not format exactly as intended.
Is the SQL I enter sent anywhere?
No. Formatting happens entirely in your browser.
Can I keep keywords lowercase?
Currently only uppercasing keywords is supported.
Notes
- Standard SQL syntax is supported (via the sql-formatter library). Database-specific dialect syntax may not format exactly as intended.
- No syntax validity check is performed. Even if the SQL contains errors, it may still be formatted as-is where possible.
- Formatting a very long SQL statement may make browser processing slow.
Related Tools
Minify SQL by removing unnecessary whitespace, line breaks, and comments.
Format YAML to make it easier to read.
Format XML to make it easier to read.