Formatted in this browser
Strings and comments stay as written. The page does not run the script or check that every block has a matching end.
Help Us Improve
—
(—)
Beautify Lua source
Reindent Lua so each block and table field is on its own line, then copy or download it. Free, with no signup.
What this Lua beautifier does
Formatting for pasted Lua
Lua beautifier
Block keywords and table braces are split onto their own lines.
2 or 4 spaces
Pick the indent width. The source is not sent anywhere.
Strings stay literal
Quoted text, long brackets, and comments are not rewritten, even when they contain the word end.
Copy or download
Copy the result, download a .lua file, or open it in a new tab.
How to beautify Lua
Paste Lua
The sample is a short function with a one-line if. Replace it with your own source.
Choose the indent
2 spaces is the default. 4 spaces uses a wider indent for the same breaks.
Copy the result
Copy, download, or open the formatted source. The page does not save it.
What the formatter will not change
A missing end stays missing
If a block was never closed, the indent can run on. The page does not add the missing end.
One statement per line is not guaranteed
Calls and assignments that already share a line can stay together. Blocks and table fields are the breaks it adds.
Keep the paste under 100,000 characters
Longer source is refused so the page stays responsive.
When the Lua is hard to read
A one-line function
Spread function, if, and for blocks so each body is indented.
A packed table
Put each top-level field on its own line.
A snippet from a log or chat
Format the paste here, then copy it back. Nothing is uploaded.
What you get
No signup
Paste and copy. There is no account step.
Free
The formatted source has no watermark.
Nothing is uploaded
Formatting runs in the browser.
What the formatter covers
Blocks
function, if, elseif, else, for, while, repeat, until, do, and end.
Left as written
Quoted strings, long brackets, and comments, including words that look like keywords.
Limit
100,000 characters. The page does not check that the script runs.
Sources & References
“Lua is cross-platform software, since the interpreter of compiled bytecode is written in ANSI C, and Lua has a relatively simple C application programming interface (API) to embed it into applications.”
Lua is an embeddable language: This page only formats pasted source. It does not include the Lua interpreter. en.wikipedia.org/wiki/Lua_(programming_language)
“A block is a list of statements, which are executed sequentially:”
A block is a list of statements: The formatter indents those blocks. It does not decide whether the statements are valid. lua.org/manual/5.4/manual.html#3.3.1