SQL Formatter
Uppercase common SQL keywords and separate clauses for readable queries.
Runs in your browser. Your input stays on this device.
What this tool does
Normalize common keyword casing and separate top-level clauses for a readable SQL statement.
When to use it
Clear clause boundaries help reviewers distinguish a filter from a result ordering or grouping change.
How to use it
- Paste a SQL statement without log prefixes.
- Choose Format SQL and inspect the line breaks.
- Review the diff against your source and test database-specific syntax in your development environment.
Worked example
Paste the sample query that selects id and email from customers, filters on active and sorts by id. Run the formatter and look for SELECT, FROM, WHERE and ORDER BY on separate lines. Add another condition using a quoted string and verify the string still contains the same characters. Use the formatted result to review a query in a code change where the clause order was hard to scan. When the query came from an application log, remove log prefixes and capture any bound parameters separately before using the result in a database client.
select id from orders where active = true order by id;SELECT id
FROM orders
WHERE active = true
ORDER BY id;Supported features and limitations
Formats common SQL syntax without running or validating a query against a database. Review vendor-specific procedural SQL before using the result.
Common mistakes and edge cases
SQL dialects differ in how they quote identifiers, represent parameters and delimit procedural statements. Review vendor-specific syntax manually, particularly if your input contains database functions or several nested statements. Formatting changes presentation and does not consult a table definition. A neatly formatted query can still reference an unknown column or have an unintended join. Keep a copy of complex input and review your diff before substituting the formatted version. A useful spot check for a report query is to compare literals, parameter markers and the ordering of clauses before and after formatting. If you need to compare actual results, use a small dataset in your normal development environment.
Frequently asked questions
- Does the formatter connect to my database?
- No database connection is needed. The tool processes the text in your browser. To verify behavior, use the parser or query tooling for your own database dialect.
- Can formatting make a query faster?
- Whitespace and keyword case help people read the query. Use your database’s execution plan to assess join strategies, indexes and other factors that affect runtime.