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.

SQL Formatter

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

Frequently asked questions

Is my SQL query sent to a server when I format it?

No. Formatting runs entirely in your browser and nothing is transmitted or stored, so queries containing table names, customer data, or credentials in string literals never leave your device.

Does formatting change what my SQL query does?

No. Only whitespace, line breaks, and keyword casing are changed — the query is never executed, validated against a schema, or rewritten, so it behaves identically when you run it.

Which SQL dialects does the formatter support?

Standard SQL, PostgreSQL, MySQL, SQLite, and BigQuery. Choosing the right dialect matters because each recognises different keywords, functions, and quoting styles — a query using BigQuery backtick identifiers, for example, formats cleanly only under BigQuery.

Can I make SQL keywords uppercase or lowercase automatically?

Yes. The Keywords option converts every recognised keyword to UPPERCASE or lowercase, or preserves the casing you pasted. Identifiers like table and column names are left as written.

How do I get a formatted SQL query back onto one line?

Set Indentation to Minify. This strips -- and /* */ comments and collapses whitespace to single spaces, while leaving quoted strings and identifiers untouched — useful for shell commands, JSON config values, or log statements.