# MySQL Formatter

Format MySQL queries and scripts with MySQL rules for backtick identifiers, backslash escapes in strings, # comments and DELIMITER blocks. Each clause starts its own line, columns and conditions are indented, and MySQL clauses such as ON DUPLICATE KEY UPDATE stay together. Unclosed strings, comments and parentheses are reported with line and column, which helps developers read and review database code.

## Frequently asked questions

### Which MySQL syntax does the formatter understand?

It reads backtick identifiers, single and double quoted strings with backslash escapes and doubled quotes, hex, bit and national literals such as X'FF', B'101' and N'text', charset introducers like _utf8mb4'text', and @user variables. Everything inside a literal stays exactly as written.

### How are comments handled?

Hash comments (#) and double dash comments (--) are kept in place. As in MySQL, a double dash only starts a comment when a space or line break follows it, so a--1 stays an expression. Executable version comments are kept as written.

### How is the query laid out?

Main clauses such as SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT start their own line with their content indented beneath. Selected columns go one per line, AND and OR start new lines and joins each get their own line.

### Are MySQL specific clauses supported?

Yes. ON DUPLICATE KEY UPDATE, LOCK IN SHARE MODE, FOR UPDATE and FOR SHARE are kept together as one clause instead of being split across lines.

### Can I format stored procedures and triggers?

Yes. DELIMITER commands stay on their own lines, the custom delimiter such as // or $$ ends the statement, and BEGIN and END blocks with IF, WHILE and LOOP are indented.

### Does it change keyword case?

No. Keywords, function names and identifiers keep the case you wrote, so select and SELECT both stay as they are. Only whitespace and line breaks change.

### Does the formatter check that my query is valid?

It checks that strings, quoted identifiers and block comments are closed and that parentheses balance, and reports problems with line and column. It does not run the query or check table names and full MySQL grammar.

### Can I change the indentation?

Yes. Choose 2 or 4 spaces or tabs for each level. Short parenthesized lists stay on one line, while longer lists and subqueries open an indented block.

### How large can the input be?

Up to 1 MB of SQL per request, with up to 128 KB in a single statement. Scripts with many statements are formatted statement by statement and separated by blank lines.

### Is my SQL stored?

No. Queries are formatted in memory and returned immediately. They are never saved and only request sizes are logged.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad The agent-ready plugin suite for WordPress.](https://sleekwp.com/?ref=oneclickpro)
