Skip to content
My Tiny Utils

Search tools

Type to find a tool, then press Enter to open it.

SQL Formatter

Format messy SQL into readable, indented queries — or minify it back down. Postgres, MySQL, SQLite, and BigQuery dialects.

Processed locally in your browser — nothing is uploaded.

0 characters

Formatted SQL

Output appears here…

About SQL Formatter

Queries copied out of logs, ORMs, or a colleague's message usually arrive as one long line. Paste one here and it comes back indented, with clauses on their own lines and keywords cased the way you prefer.

Pick the dialect that matches your database so dialect-specific keywords and functions are recognised. The minify option strips comments and collapses whitespace when you need the query back on a single line for a config file or a log statement.

Common uses

  • Make a one-line query from an ORM log readable before debugging it
  • Normalise formatting across a team's migration files
  • Flatten a formatted query into one line for a shell command or JSON field

Example

Input

select id, name from users where age > 21 order by name

Output

SELECT
  id,
  name
FROM
  users
WHERE
  age > 21
ORDER BY
  name

Limitations

  • Formatting only — the query is never executed, validated against a schema, or optimised
  • Very unusual vendor extensions may not be recognised by the chosen dialect