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

Lua Beautifier reindents pasted Lua. function, if, for, while, repeat, and do blocks each start on a new indented line, and table fields do too. Strings and comments are copied as written. It does not run the script.

Formatting for pasted Lua

Indent and line breaks, in the browser.
  • 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 the source. The formatted copy updates as you type.
  1. Paste Lua

    The sample is a short function with a one-line if. Replace it with your own source.

  2. Choose the indent

    2 spaces is the default. 4 spaces uses a wider indent for the same breaks.

  3. Copy the result

    Copy, download, or open the formatted source. The page does not save it.

What the formatter will not change

It moves lines. It does not rewrite names.
  • 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 pasted snippet, not a project.
  • 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

Readable Lua, still the same script.
  • 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

Indent from Lua block words and braces.
  • 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

What Lua is, and what a block is in the language.
  • “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.”
    — Wikipedia — Lua

    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:”
    — Lua 5.4 Reference Manual — Blocks

    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

Frequently Asked Questions

Quick answers about this tool—open a question to read more.