Hongmu Notes

🗄️ SQL formatting

Beautify or compress SQL statements with one click and replace content in place.

SQL formatting

Instructions for use

  • Paste SQL into the input box and click "Format SQL" or "Compress SQL"
  • The result will be written back to the input box on the spot. It is recommended to make a backup copy of the original text first.
  • Formatting only adjusts whitespace and line breaks, but does not change the statement itself.

Format SQL

When a long string of SQL is squeezed into one line, the table name and conditions cannot be clearly seen; after formatting, it is separated into lines by keywords, which makes reading much faster.

📌 Will formatting change the statement?

No. Only line breaks and indents (four spaces) are rearranged. Keywords, field names, strings, and comments remain unchanged, and the case is not changed.

📌 Processing rules

For formatting, the local SQL formatting library on the site is called: line breaks are rearranged according to keywords and bracket structures such as SELECT, FROM, WHERE, JOIN, GROUP BY, etc., and the indentation is uniformly four spaces; for compression, the local compression library on the site removes line breaks, tabs, and extra spaces, and puts the statements back into one line. Both do not rewrite identifiers, strings, and comment contents; if the statement syntax is incomplete, the formatting library may give a parsing failure prompt, and the content of the input box remains unchanged.

🧭 Common uses

The SQL copied from the log or monitoring is often a whole line. Formatting it first and then reading it can quickly see the table name and conditions; compressing the SQL into one line before pasting it into code, work orders or configurations can avoid unnecessary line breaks that affect typesetting. When doing code review and troubleshooting, I often switch back and forth between the two forms.

All keywords and tutorials 12

❓ FAQ

Can the indentation be adjusted?
No. This page has a fixed four-space indentation, consistent with the original tool.
What database syntax is supported?
Common SQL writing methods can be processed; dialect-specific syntax may not be ideal for typesetting.
Usage scenarios for formatted SQL
Read long statements in logs, code reviews, and give SQL to colleagues for review.