SQL Formatter

Beautify SQL queries with consistent indentation, one column per line and optional upper-case keywords.

Runs in your browser Free
Indent
Processed locally in your browser.

The formatter works on tokens, so strings, quoted identifiers and comments are never changed.

Readable SQL

Long queries generated by ORMs, copied from logs or written on one line are hard to read and debug. The SQL Formatter arranges your query by structure: every major clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY), joins, subqueries and CASE expressions get their own lines.

Safe editing

The query is tokenised first, so string values, quoted identifiers and comments are never altered. Optionally upper-case keywords and put every column on its own line.

Dialect support

Standard SQL plus common MySQL, PostgreSQL, SQL Server and SQLite syntax are supported. Your query is processed in the browser, so table names and data aren't sent anywhere.

How to use SQL Formatter

  1. Paste your SQL query.
  2. Set the keyword case and indentation options.
  3. Review the formatted query.
  4. Copy the result.

Why use this tool?

Produces consistent, readable SQL for code reviews, documentation and debugging.

FAQ

Which SQL dialects are supported?

Standard SQL plus common MySQL, PostgreSQL, SQL Server and SQLite syntax. Unusual vendor-specific syntax is kept as written.

Does it run my query?

No, it only formats; it never connects to a database.

Can it format stored procedures?

It formats the basic statements; some lines in complex procedural blocks may stay as written.

Related tools