convert

SQL Formatter

Format SQL queries with uppercase keywords and one clause per line for readable code reviews.

Runs on your deviceBatch readyPaste textNew

Paste or drop

Paste text below, or drop a file instead.

0 chars · 0 lines
…or drop a file
Drag and drop, or choose files
SQLTXT

Choose an output

Format SQL queries with uppercase keywords and one clause per line for readable code reviews.

Fine-tune

Optional — sensible defaults are already set.

Indent

About SQL Formatter

This formatter puts each major clause of a SQL statement, such as SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY, on its own line, indents column lists and AND/OR conditions, and indents subqueries in parentheses. Keywords can be uppercased or lowercased consistently.

When it helps

  • Making a long query copied from an ORM log or a monitoring tool readable.
  • Formatting SQL before pasting it into a pull request, ticket or documentation.
  • Understanding a nested query by seeing its subqueries indented.

Tips

  • String literals, quoted identifiers and comments are kept exactly as written, including their case.
  • Turn off "UPPERCASE keywords" to get lowercase keywords if your team prefers that style.
  • The formatter is not dialect-aware and does not check syntax, so it can format invalid SQL without complaint. Run the query to check it.
  • Separate statements ending with ; are formatted one after another with a blank line between them.

Good to know

Quick answers about sql formatter in your browser.

No. Only whitespace and keyword case change. SQL keywords are case-insensitive, and string contents and quoted identifiers are not touched.

Common syntax from PostgreSQL, MySQL, SQLite and SQL Server formats well, including backtick, double-quote and bracket-quoted identifiers. Vendor-specific procedural code such as PL/pgSQL blocks gets only basic formatting.

Yes. There is no sign-up, no watermark and no limit on how many files you process.

No. Files are read and processed locally in your browser, so they never leave your device.

Related tools