Paste a cramped one-line SQL query and get back a readable, reviewable layout. Each major clause goes on its own line, recognised keywords are upper-cased, and long conditions and select lists wrap onto indented continuation lines — ideal for pull requests, documentation, and debugging.
How it works
The formatter is a layout pass, not a parser:
- Tokenise. The query is broken into tokens on whitespace, parentheses, and quote boundaries. Quoted strings and identifiers (
'...',"...",`...`) are detected here and passed through untouched. - Line breaks. Major clauses —
SELECT,FROM,WHERE, theJOINfamily,GROUP BY,ORDER BY,LIMIT, and more — start a new line.AND/ORand commas in the SELECT list break onto indented continuation lines. - Casing. Only recognised keywords are upper-cased; your identifiers keep their original case.
Because it re-lays-out rather than validates, it will not flag syntax errors — but it also never changes what your query does.
Example
Input:
select id, name, email from users where active = true and country = 'GB' order by name
Formatted (2-space indent):
SELECT
id,
name,
email
FROM users
WHERE active = true
AND country = 'GB'
ORDER BY name
Note the string literal 'GB' is preserved exactly. It is privacy-first plain JavaScript — your query never leaves your device.