MySQL Query Formatter

Format MySQL queries online with backtick identifiers and MySQL functions handled correctly. Paste your query, pick MySQL and beautify it.

Part of the free SQL Formatter. Runs in your browser — nothing is uploaded.

MySQL Query Formatter

MySQL queries often include backtick-quoted identifiers and functions like DATE_FORMAT. Choose the MySQL dialect and those are respected, giving you clean, review-ready SQL from slow-query-log lines or ORM debug output.

Worked example: Backticks and DATE_FORMAT in MySQL

Input

select id, name, date_format(created_at, '%Y-%m-%d') as day from `users` where status = 'active' order by created_at desc limit 20;

Formatted MySQL

SELECT
  id,
  name,
  date_format(created_at, '%Y-%m-%d') AS day
FROM
  `users`
WHERE
  status = 'active'
ORDER BY
  created_at DESC
LIMIT
  20;

Practical tip

Copy queries from the slow query log after removing the trailing "SET timestamp" lines so only the statement itself is formatted.

How to use this SQL Formatter

  1. 1Use the live tool above — it runs entirely in your browser and never uploads your data.
  2. 2Paste the sample from the worked example, or use your own input.
  3. 3Copy the result, then adapt the same steps in your editor, script, or pipeline.

MySQL Query Formatter FAQs

Does it keep backtick identifiers?

Yes. Backtick-quoted table and column names are preserved exactly as written.

Does it work for MariaDB?

MariaDB is close to MySQL. Pick the MariaDB dialect for the best match, or MySQL if the query uses only common syntax.

More SQL Formatter pages

Open the full SQL Formatter tool →