Advertisement

MySQL Formatter

Paste a MySQL query and get it back with uppercase keywords, one clause per line and indented subqueries. Handles MySQL specifics like AUTO_INCREMENT, backtick identifiers and ON DUPLICATE KEY UPDATE.

MySQL

Paste a MySQL query below.

Advertisement

How the MySQL formatter works

The tool protects strings, backtick identifiers and comments, then uppercases MySQL keywords including AUTO_INCREMENT, IFNULL and GROUP_CONCAT. SELECT, FROM, WHERE and JOIN clauses each get their own line, AND and OR conditions are stacked, and subqueries are indented by parenthesis depth.

Why format SQL before sharing

Formatted queries are faster to review in pull requests and easier to debug when a WHERE clause misbehaves. Consistent keyword casing also helps teammates spot a missing JOIN condition or a duplicated column at a glance.

MySQL Formatter FAQs

Does it work with stored procedures?
Basic procedure bodies format fine, but DELIMITER statements and complex control flow are treated as plain text. Check the output around BEGIN and END blocks before saving.
Are my string values safe?
Yes. Single quoted, double quoted and backtick quoted sections are masked before any keyword is uppercased, so text like 'select' inside a string is never changed.
Can it format CREATE TABLE statements?
Yes. CREATE TABLE, column definitions and constraints like PRIMARY KEY are recognized and uppercased, with each major clause on its own line.
Does it validate the query?
No. It is a formatter, not a parser, so a query with a syntax error will still be reformatted. Run it against MySQL to verify correctness.
Is there a PostgreSQL version?
Yes, this site has dedicated PostgreSQL, SQLite and T-SQL formatters with their own dialect keyword lists. Use the one matching your database.
Advertisement