Skip to content
๐Ÿ—„๏ธ

SQL Prettifier

Developer

Format SQL with indentation and optional uppercase keywords; check quote and parenthesis balance.

0
0
Input

Standard mode also covers MySQL NO_BACKSLASH_ESCAPES. PostgreSQL mode assumes standard_conforming_strings is on. Lexical SQL formatting preserves quoted text and comments. Checks quote and parenthesis balance; it does not validate database-specific SQL grammar.

Output

SQL formatter that starts each major clause on its own line and indents inside parentheses, with optional uppercase keywords. It is lexical formatting: quoted text and comments are kept intact, unbalanced quotes or parentheses are reported, and SQL syntax is not checked.

See more about the SQL Prettifier

Examples

Clause layout

select id,name from users where id=1 โ†’ SELECT id,name
FROM users
WHERE id=1

Spacing comes from your input, so a comma without a space stays that way. Turn off Uppercase keywords to keep the original case.

Unbalanced input

select (id from users โ†’ Unbalanced SQL parentheses.

Quote and comment errors are reported too, such as Unterminated SQL quote. A misspelled keyword is not flagged, because syntax is not checked.

Key features

  • Clause-based line breaks
  • Uppercase keywords option
  • 2 or 4 space indent
  • Quote and parenthesis checks

Quick answers for SQL Prettifier

Does it check that my SQL is valid?
No. Formatting is lexical: it breaks lines at clause keywords and checks quote and parenthesis balance. It does not parse the grammar, so a wrong keyword order is not reported.
What does Uppercase keywords change?
It uppercases recognized SQL keywords such as select, from and where. Table names, identifiers and unknown words keep their case.
Which dialects are supported?
Standard SQL is the default. PostgreSQL mode reads E-string escapes and MySQL mode reads backslash escapes inside quoted strings. The dialect only changes how quotes are read.
Does it change spacing around commas and operators?
No. It keeps the spacing from your input, so a comma without a space stays that way and no space is added around =.