MySQL Formatter & Beautifier

Format and beautify MySQL queries in your browser, from quick SELECTs to stored procedures, with backtick identifiers left as written.

Client-side only, nothing leaves your browser

Formatted SQL will appear here...

Formatting MySQL Queries

MySQL code picks up habits other engines do not have: backtick-quoted identifiers, LIMIT instead of TOP, and ON DUPLICATE KEY UPDATE on inserts. This formatter uses the MySQL dialect of sql-formatter, so backticks, the -> and ->> JSON operators and INTERVAL arithmetic come through unchanged while clauses get their own lines. Strip DELIMITER lines from stored procedure scripts before pasting, then add them back.

Supported Features

  • Queries: SELECT, INSERT, UPDATE, DELETE, REPLACE
  • DDL: CREATE TABLE, ALTER TABLE, CREATE INDEX, DROP
  • MySQL syntax: backticks, LIMIT, ON DUPLICATE KEY UPDATE, INTERVAL
  • Advanced: CTEs, window functions, JSON operators (->, ->>)

Formatting Styles

StyleDescriptionExample
StandardKeywords on new lines, indented clausesSELECT
col
FROM
table
Tabular LeftKeywords left-aligned in columnSELECT col
FROM table
WHERE x = 1
Tabular RightKeywords right-aligned in columnSELECT col
  FROM table
 WHERE x = 1

Frequently asked questions

Is a MySQL beautifier the same as a MySQL formatter?
They are two names for the same job. A beautifier rewrites only whitespace, line breaks and keyword case, so the query returns exactly the same rows after formatting. Identifiers in backticks and string literals are left as you wrote them.
Does MySQL Workbench have a formatter?
MySQL Workbench has a Beautify Query command under Edit > Format, bound to Ctrl+B on Windows and Linux and Cmd+B on macOS. It uppercases keywords by default, which you can change in the SQL Execution section of Preferences. It only reformats SQL it can parse, so a half-written query is left alone.
How do I format a MySQL stored procedure?
Remove the DELIMITER lines and the custom terminator (such as // or $$) before you paste, and end the procedure with a plain semicolon. The formatter reads DELIMITER as ordinary text, so a terminator like // gets split apart. Once the body is formatted, put DELIMITER // and DELIMITER ; back around it before running the script in the mysql client.
Can I format MySQL in VS Code?
The SQL Formatter VSCode extension, maintained alongside the sql-formatter library this page uses, formats .sql files with Format Document. Set its dialect option to MySQL explicitly, because otherwise it guesses from your editor setup and may parse backticks or MySQL keywords wrong. An online formatter is quicker for a one-off query or when you are not in your usual editor.
Does the formatter handle MySQL JSON queries?
The -> and ->> operators and functions like JSON_EXTRACT and JSON_OBJECT are formatted like any other expression, with spaces around the operator and the path string left intact. JSON stored inside a string literal is not pretty-printed, since the formatter treats it as plain text. To read a JSON document from a column, paste it into a JSON formatter instead.
MySQL

Need a MySQL GUI Client?

1bench is a modern database client for MySQL and 20+ other databases. Query, browse, and manage your data visually.

Learn More