Mr. Encoder

SQL Formatter

Format, beautify and minify SQL queries for many database dialects.

How to use

  1. Paste your SQL query into the input box.
  2. Choose the database dialect, keyword case and indentation.
  3. Click Format to beautify or Minify to compress it, then copy the result.

Frequently asked questions

Why should I pick the correct SQL dialect?

Each database has its own syntax, such as T-SQL square-bracket identifiers, PostgreSQL :: casts or MySQL backticks. Choosing the right dialect lets the formatter recognise these constructs instead of failing with a parse error.

Does formatting change what my query does?

No. Only whitespace, line breaks and (optionally) keyword case change. String literals, identifiers and comments are kept as they are.

What does Minify do?

Minify collapses all whitespace into single spaces and removes comments while leaving string literals and quoted identifiers untouched. Optimizer hints (/*+ ... */) and MySQL executable comments (/*! ... */) are kept because they affect execution.

Is my SQL sent to a server?

No. Formatting runs entirely in your browser, so queries containing table names or data never leave your computer.

Other tools