MySQL Formatter
Format MySQL-flavored SQL with MySQL-specific syntax support.
What Is a MySQL Formatter?
A MySQL formatter rewrites MySQL (and MariaDB) queries with consistent indentation, keyword casing, and clause alignment. It understands MySQL-specific syntax including backtick identifiers (`column`), LIMIT … OFFSET, ON DUPLICATE KEY UPDATE, STRAIGHT_JOIN, and the RAND()/NOW() function family. Formatted MySQL is dramatically easier to read, debug, and review.
MySQL Formatter Online — What This Tool Does
This free MySQL formatter beautifies MySQL queries entirely in your browser using the sql-formatter library with the MySQL dialect preset. Supports keyword casing (UPPER/lower/preserve), 2/4/tab indent, and comment stripping. Runs entirely locally — your queries never leave your machine.
How to Format MySQL Queries
- Paste your MySQL or MariaDB query into the Input pane, or click Upload to load a
.sqlfile. - Confirm the dialect is MySQL (selected by default for this route).
- Pick keyword case — ABC (uppercase, standard), abc (lowercase), or – (preserve original).
- Pick indent: 2 spaces, 4 spaces, or tab.
- Optional: enable No comments to strip
--and/* */comments first. - Click Format. The formatted query appears in the output pane.
- Click Copy or Download.
MySQL-Specific Syntax Handled
- Backtick identifiers —
`order`for reserved words used as column names. LIMIT … OFFSET— paginated result clauses.ON DUPLICATE KEY UPDATE— upsert syntax unique to MySQL.INSERT IGNORE— silently skip duplicate-key conflicts.- STRAIGHT_JOIN, FORCE INDEX — optimiser hints specific to MySQL.
- Storage engine hints —
ENGINE=InnoDBin DDL.
MySQL vs PostgreSQL Formatting Differences
MySQL uses backticks for identifiers; PostgreSQL uses double-quotes. MySQL has LIMIT … OFFSET and ON DUPLICATE KEY UPDATE; PostgreSQL has LIMIT + OFFSET on separate lines and ON CONFLICT. Always pick the matching dialect — formatting MySQL with the PostgreSQL preset can mangle backtick identifiers and unrecognised reserved words.
Common Use Cases
- Code review — format auto-generated MySQL from ORMs (Doctrine, Eloquent, Sequelize) for human review.
- Stored procedure cleanup — beautify legacy stored procs before refactoring.
- Migration scripts — format migrations before merging to keep diffs clean.
- Onboarding — format unfamiliar queries for easier learning.
Tips & Tricks
- Uppercase keywords for the SQL standard look — most MySQL conventions use
SELECT,FROM,WHEREin UPPER. - Test in MySQL Workbench — paste the formatted output to verify execution.
- Strip comments before sharing in tickets — internal comments may contain sensitive context.
- Use the SQL Minifier when embedding queries in code.
Related Tools
- SQL Formatter — generic ANSI SQL formatting.
- PostgreSQL Formatter — PostgreSQL-specific dialect.
- SQL Beautifier — alternate naming for the same operation.
- SQL Minifier — opposite operation, compress SQL.
- JSON to SQL — generate MySQL INSERTs from JSON.
Is My SQL Sent to a Server?
No. MySQL formatting runs entirely in your browser using the sql-formatter library. Your queries — including any production credentials, table names, or business logic — never leave your machine.