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.

SQL indentation

When subqueries are nested with parentheses, it is most likely to misread the scope if the indentation is messed up; after unified indentation, the hierarchical relationship will be clear at a glance.

📌 Indentation is how many spaces

Unify four spaces. The original tool is fixed with four spaces, and this page remains consistent to facilitate unified coding style within the team.

🧭 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.

🔒 Dealing with location and privacy

Formatting and compression are completed locally in the browser. There is no Internet access, no uploading, and no writing to local storage. It will be cleared after refreshing. SQL often contains table names and field names. Please save the results according to internal specifications, and it is recommended to paste only necessary statement fragments for processing.

All keywords and tutorials 12

❓ FAQ

Can it be changed to tab character?
cannot. If you need tab characters, please convert them uniformly in the editor.
Will nested subqueries be handled?
Yes. Indent according to the bracket level.
Checkpoints for SQL indentation
Look at the opening and closing positions of the brackets layer by layer to confirm that the nesting levels correspond correctly.