MySQL Formatter

Beautify MySQL queries with a formatter that understands backtick identifiers, # comments and MySQL-only clauses.

Runs in your browser

SQL

Formatted SQL

Your SQL is processed in this browser tab and never uploaded.

How to use the MySQL Formatter

  1. Paste your MySQL query into the editor, or press Sample to load an example.
  2. The MySQL dialect is already selected, so dialect-specific syntax is parsed correctly.
  3. Press Format (Ctrl + Enter). Pick indentation and keyword case in the options.
  4. Copy the result or download it as a .sql file.

Example

A MySQL query before formatting
Input
insert into `order_items` (`order_id`,`sku`,`qty`) values (1,'A-100',2),(1,'B-200',1) on duplicate key update `qty` = `qty` + values(`qty`);

MySQL syntax this formatter understands

  • Backtick-quoted identifiers such as `order` or `user name` are preserved exactly, including any spaces inside them.
  • MySQL comment styles are recognised: -- comments, # comments and /* */ blocks, including /*! version-specific */ hints.
  • MySQL clauses like LIMIT offset, count, ON DUPLICATE KEY UPDATE, REPLACE INTO and INSERT IGNORE are laid out as their own blocks.
  • For MariaDB-only syntax, choose MariaDB in the dialect menu; it has its own grammar.

What it does

MySQL-aware parsing
Uses the MySQL grammar from the open-source sql-formatter library, so syntax that is specific to MySQL is handled correctly.
Keyword case control
Keep the original case, or convert all keywords to UPPERCASE or lowercase as you format.
Private by design
Formatting happens on your device. Nothing you paste leaves the browser.

Frequently asked questions

Is my MySQL query sent to a server?

No. The formatter runs entirely in your browser. Your query is never uploaded, logged or stored, so it is safe to paste production SQL.

Will formatting change what my query does?

No. Only whitespace, line breaks and (if you choose) keyword case change. String literals, quoted identifiers and comments are kept exactly as written.

Does it validate my query?

The formatter has to parse your query, so badly broken SQL produces an error with its location. It does not check that tables or columns exist, and some invalid queries still format.