Skip to content

SQL formatter and minifier

Make a one-line SQL query readable: clauses on new lines, indented columns and conditions, uppercase keywords. Or minify it. Nothing is sent.

  • Free
  • No sign-up
  • No file uploaded
  • Windows, Mac, Android, iPhone

Loading the tool…

About this tool

Paste an unreadable SQL query, generated by an ORM or copied from a log: it is reformatted with one clause per line, indented columns and conditions, and nested subqueries. The tool works with MySQL, PostgreSQL, SQLite and SQL Server, and never touches strings or comments.

When to use it

Reading a generated query

ORMs (Prisma, Hibernate, Doctrine, Eloquent) and slow query logs produce one-line queries. Formatted, their joins and conditions become readable, which helps understand a performance problem.

Preparing a code review

A well-indented query in a migration or report is easier to read and comment on. Uppercase keywords visually separate the structure from table and column names.

Shortening a query

Minify mode removes comments and extra whitespace so a query fits in a code string, an environment variable or a tool that only accepts one line.

How to use

  1. Paste the SQL query.
  2. Choose to format or minify it.
  3. Copy or download the result.

How it works

The query is split into tokens: words, numbers, single-quoted strings, identifiers in double quotes, brackets or backticks, comments and symbols. Strings and comments are copied verbatim, which guarantees the meaning of the query does not change.

Main clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY…) start a new line; SELECT columns, AND and OR conditions and join ON clauses are indented. A parenthesis that opens a subquery increases the indentation level, while function calls such as COUNT(*) stay on the line.

Tips for best results

  • Keep the same case convention across a project: uppercase keywords and lowercase names is the most common.
  • A formatted query quickly reveals a Cartesian product: a join without ON stands out.
  • Before pasting a production query, remove sensitive values (emails, tokens) from the conditions.
  • To understand a slow query, format it and then run it through EXPLAIN in your database.
  • In code, prefer parameterised queries over concatenating values: that is the protection against SQL injection.

Common problems and fixes

Part of the query stays on one line

Stored procedures or very dialect-specific syntax are not all recognised. The query is still correct: only line breaks are missing.

A column name became uppercase

Some names coincide with a keyword (date, key, text). Untick the uppercase option or quote the name in the query.

My string has changed spaces

That cannot happen: single-quoted strings are copied exactly. Check that a quote is not left unclosed in the original query.

Frequently asked questions

Which SQL dialects are supported?

The common syntax of MySQL, MariaDB, PostgreSQL, SQLite, SQL Server and Oracle. Identifiers in backticks, brackets or double quotes are recognised.

Is the query executed?

No. It is only formatted in your browser; no database is contacted and nothing is sent.

Can formatting break my query?

No: only whitespace, line breaks and keyword case change. SQL ignores these differences.

Can I format several queries at once?

Yes, separate them with semicolons: each one starts on a new line.

Related searches

Still stuck?

Ask on the forum: the category, the tool, your device sheet and the test result will be filled in for you.