Tool Logo

SQL Formatter

Turn long one-line SQL queries into clean, readable statements.

0 characters

Loading tool…

How to use the sql formatter

Paste a query, however long, and the formatter puts each clause (SELECT, FROM, WHERE, JOIN, ORDER BY) on its own line with consistent indentation. It uses the sql-formatter library, which understands each dialect's syntax, so text inside quotes such as 'in stock' is never changed. You choose the dialect, keyword case and indentation.

  1. Paste your SQL or upload a .sql file.
  2. Choose the SQL dialect, keyword case and indentation.
  3. Copy the formatted SQL.

When to use it

  • Queries from logs

    Make a one-line query from an ORM or a slow-query log readable.

  • Code reviews

    Format SQL consistently so changes are easy to see.

  • Documentation

    Paste readable queries into docs, tickets and reports.

Frequently asked questions

Which SQL dialects are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL) and BigQuery.

Does formatting change my query?

No. Only whitespace and, if you choose, the case of keywords change. Table names, column names and text inside quotes stay exactly as written.

Can I format several statements at once?

Yes. Separate them with semicolons and each statement is formatted in turn.

Does it check my SQL for errors?

Only enough to format it. To check syntax, use the SQL Validator.

Is my SQL uploaded?

No. Everything runs in your browser; nothing you paste or upload is sent to our servers.