Developer Tools

SQL Formatter

Turn long, single-line or auto-generated SQL into clean, readable queries. Choose your database dialect and keyword style, then copy the formatted SQL into your editor, documentation or code review.

Format SQL

Paste one or more SQL statements, choose the dialect and press Format.

How to Format SQL

  1. Paste your query, for example from application logs, an ORM's debug output or a colleague's message.
  2. Choose the dialect that matches your database so its special syntax is recognised.
  3. Choose UPPERCASE or lowercase keywords and press Format SQL.

Before and After

select u.id,u.name from users u left join orders o on o.user_id=u.id where u.active=1

SELECT
  u.id,
  u.name
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.active = 1

Why Format SQL?

  • Find bugs faster: one column per line makes missing commas, wrong joins and misplaced conditions obvious.
  • Review queries from ORMs such as Laravel Eloquent, Django, Hibernate or Prisma, which log SQL as one long line.
  • Consistent style in code reviews, migrations and documentation.

Formatting changes only whitespace and keyword case, never the meaning of the query. String values and comments are kept exactly as written.

Supported Dialects

The formatter uses the open-source sql-formatter library and understands MySQL and MariaDB backtick identifiers, PostgreSQL casts and dollar-quoted strings, SQL Server square-bracket names and T-SQL syntax, Oracle PL/SQL, SQLite and BigQuery. If you are unsure, Standard SQL works for most queries.

Privacy

Your queries are formatted in your browser. Table names, data and credentials in your SQL are never uploaded.

Frequently Asked Questions

Does formatting change what my query does?

No. Only whitespace, line breaks and the case of SQL keywords change. Strings, identifiers and comments stay the same.

Which databases are supported?

MySQL, MariaDB, PostgreSQL, SQL Server, SQLite, Oracle PL/SQL, BigQuery and standard SQL.

Can I format several queries at once?

Yes. Separate them with semicolons and they are formatted with a blank line between each.

Why do I get an error?

The query may use syntax from a different dialect. Choose the dialect that matches your database, or check for unclosed quotes or brackets.