MySQL Formatter
Paste a MySQL or MariaDB query to beautify it with MySQL syntax rules. The MySQL dialect is already selected.
Advertisement
Format MySQL queries online
Queries from the MySQL slow query log, a Laravel or WordPress debug bar, or phpMyAdmin's history are often a single long line. This MySQL formatter breaks them into readable clauses with consistent indentation, which makes slow-query tuning and code review much easier.
It understands MySQL syntax such as `backtick` identifiers, LIMIT, INTERVAL expressions and MySQL functions, and works the same for MariaDB. Everything runs in your browser — your queries are never uploaded.
Example: a MySQL report query
Before:
select `p`.`sku`,`p`.`name`,count(*) as sold from `order_items` oi join `products` p on p.id=oi.product_id where oi.created_at>now()-interval 30 day group by p.sku,p.name order by sold desc limit 20After formatting:
SELECT
`p`.`sku`,
`p`.`name`,
count(*) AS sold
FROM
`order_items` oi
JOIN `products` p ON p.id = oi.product_id
WHERE
oi.created_at > now() - interval 30 day
GROUP BY
p.sku,
p.name
ORDER BY
sold DESC
LIMIT
20Frequently asked questions
- Does it work for MariaDB?
- Yes. MariaDB uses the same query syntax as MySQL for everyday SELECT, INSERT, UPDATE and DELETE statements, so the MySQL dialect formats it correctly.
- Will it remove my backticks?
- No. Backtick-quoted table and column names are kept exactly as written. Only whitespace, line breaks and keyword case change.
- Can I format a whole .sql dump?
- You can paste several statements separated by semicolons and each is formatted. For very large dumps with thousands of INSERT rows, a command-line tool is faster.
- Is my query sent to a server?
- No. Formatting happens entirely in your browser, so your schema and data stay on your computer.