EN
My tools

SQL Formatter

Format SQL for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake and more: keyword case, indent, or minify. Errors show line and column.

Output
My tools →
Advertisement

Long queries pasted from logs, ORMs or BI tools are usually one unreadable line. The formatter puts each clause — SELECT, FROM, JOIN, WHERE, GROUP BY — on its own line, indents what belongs to it and sets the keyword case you prefer, using the grammar of the database you choose. Minify does the reverse: it strips comments and extra whitespace for embedding a query in code.

How to use this tool

  1. Paste one or more SQL statements.
  2. Choose the dialect, such as MySQL, PostgreSQL or SQL Server, so its quoting and keywords are understood.
  3. Pick keyword case, indentation and the blank lines between statements.
  4. Copy the result, or switch to Minify for a compact one-line version.

Formula

clause keyword on its own line; clause body indented one level; one column or condition per line; AND / OR start new lines

Formatting uses the open-source sql-formatter library, which tokenizes each dialect separately — backtick names for MySQL, [brackets] for SQL Server, $$ strings for PostgreSQL. Minify is a separate tokenizer: it never touches the inside of strings or quoted names and keeps optimizer hints (/*+ … */) and MySQL /*! … */ blocks, because removing them can change how a query runs.

Example

The sample report query on one line becomes 20 lines: SELECT with three indented columns, FROM orders, two JOINs with their ON conditions, a WHERE whose two conditions are joined by AND on separate lines, then GROUP BY, HAVING, ORDER BY total DESC and LIMIT 20. Keywords and function names such as SUM are upper-cased; table names, aliases and the dates in quotes stay exactly as typed.

Frequently asked questions

Why do I get a parse error?

Usually a quote that is never closed, or syntax from one database checked as another — for example square-bracket names under Standard SQL. Choose your database in Dialect; the error shows the line and column where reading stopped.

Does formatting change what my query does?

No. Only whitespace and the letter case of keywords change; identifiers, strings and comments are kept. Keyword case does not matter to SQL databases.

Is it safe to paste production queries?

Yes. Formatting runs in your browser and nothing is sent to a server.

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). SQL Formatter. https://kakao.mobile/tools/sql-formatter/

MLA

“SQL Formatter.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/sql-formatter/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement