Utils365

SQL formatter

Make long SQL queries easy to read, in your database’s dialect.

Paste SQL, open a .sql file, or drop one here

Next: JSON formatter · Diff checker

Report a problem with this tool

How to use SQL formatter

  1. Paste your query

    Paste one or more SQL statements, or open or drop a .sql file. It’s formatted as you type.

  2. Pick a dialect and case

    Choose your database so its syntax is understood, and keep keywords as written or make them UPPER or lower case.

  3. Copy or download

    Copy the formatted SQL, or download it as a .sql file.

Why use Utils365

  • Seven dialects

    Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle (PL/SQL) and BigQuery, each with its own quoting, comments and keywords.

  • Consistent keywords

    Make SELECT, FROM and JOIN upper or lower case throughout, so queries from different people look the same.

  • Errors with a position

    A query the formatter can’t read shows the line and column, with the spot marked.

  • Private by design

    Your queries are formatted in your browser and never uploaded, so table names and data in them stay with you.

Frequently asked questions

Which SQL dialect should I choose?

The one your database uses. Standard SQL works for most simple queries, but things like MySQL backticks, PostgreSQL :: casts and SQL Server [brackets] need their own dialect.

Does formatting change what my query does?

No. Only spaces, line breaks and, if you choose, the case of keywords change. Table names, column names and text in quotes stay exactly as written.

Why does it say something isn’t expected?

The formatter couldn’t read the query at that point. Often it’s syntax that belongs to one database, such as # comments in MySQL. Pick your database’s dialect and try again.

Can I format several queries at once?

Yes. Paste them together, separated by semicolons, and each one is formatted with a blank line between them.

Does it check that my query is correct?

Only that it can be read. It doesn’t know your tables, so a misspelled column name won’t be caught until you run the query.