Lua Code Formatter: Re-indent function, if, for and end Blocks
Fixes the indentation of Lua scripts using block keywords and brackets.
Use the tool
Why this tool exists
Lua marks blocks with words rather than braces, so copied or generated scripts lose their layout easily. The tool counts function, if, for, while, repeat, do and end, treats else and elseif as part of the block, and counts brackets and braces too.
Strings, long strings and comments are skipped when counting. It does not rewrite spacing inside lines and it does not check syntax. No Lua interpreter was available to test against, so it was checked by reading and by confirming that only whitespace changes.
How to use it
- Paste Lua code.
- Pick the indent.
- Read the result.
- Run a Lua linter for syntax.
Frequently asked questions
Does it check my syntax?
No. A missing end will throw the indentation off, which can help you find it.
What about goto labels?
They are treated as normal lines.
Are long strings safe?
Yes. Lines inside them are kept exactly.
Is my input sent anywhere?
No. Everything runs in your browser and nothing is uploaded.