Developer Tools Runs in your browser Free · no account

SQL Formatter

The SQL formatter breaks a long query onto separate lines at the major clauses, indents subqueries and joins, and normalises keyword case. It is designed for reading generated or minified SQL from a log rather than for rewriting a query.

Options
SQL query 0 characters
Formatted SQL

Your result will appear here.

Not sure where to start? Use Load example.

Results update automatically and are calculated on your device. Nothing you type is sent to a server.

Runs in your browser. Processing happens entirely in your browser. Nothing you enter is sent to Delimiter.live.

How to use the SQL Formatter

  1. Paste the query, including one copied straight out of a slow-query log.
  2. Choose whether keywords should be uppercased.
  3. Read the indented result, then copy it into your editor.

Example

Input
select * from users where id = 1
Output
SELECT *
FROM users
WHERE id = 1

Common use cases

  • Making a generated ORM query readable while debugging performance.
  • Tidying a query before adding it to a repository.
  • Understanding an unfamiliar query with several joins and subqueries.

Limitations and things to watch for

  • The formatter is token-based, not a full SQL parser, so it works across dialects but does not understand vendor-specific syntax deeply. String literals, quoted identifiers, and both -- and /* */ comments are preserved exactly.
  • Very long expressions inside a single clause are not wrapped, because breaking them safely requires understanding operator precedence.
  • Formatting never changes what a query does; only whitespace and keyword case are altered.

Frequently asked questions

Which SQL dialects are supported?
Formatting is token-based and works with MySQL, PostgreSQL, SQL Server, SQLite and Oracle syntax. Because it does not parse dialect-specific grammar, unusual vendor extensions are passed through unchanged rather than being reformatted.
Is it safe to paste a query from production?
The formatting runs entirely in your browser and nothing is transmitted. Still, remember that a query pasted from a log may contain literal customer data in its WHERE clause.
Does it change what the query does?
No. Only whitespace and the case of recognised keywords change. Strings, identifiers and comments are preserved character for character.

Share this tool