Lua Beautifier

Format and indent Lua source code.

The Lua Beautifier re-indents Lua source code according to its block structure. Choose 2 spaces, 4 spaces or tabs, paste or open a .lua file, and press Beautify Lua. It is meant for developers cleaning up scripts for games, game mods, embedded configs and plugins.

What is Lua?

Lua is a lightweight, embeddable scripting language created at PUC-Rio in Brazil in 1993. It is widely used for game scripting, configuration, and extending applications such as Neovim, Redis and many game engines. Blocks in Lua are closed with keywords rather than braces: function, if, do and repeat open blocks, while end or until closes them. Tables written with curly braces are the main data structure. Because indentation carries no meaning in Lua, it is purely a readability choice, so a formatter can safely rewrite leading whitespace as long as the block structure is understood.

How to use Lua Beautifier

  1. Add Lua code Paste into the Lua input, or use the file button to open a .lua or text file.
  2. Choose the indent Set Indent to 2 spaces, 4 spaces or Tab.
  3. Format Press Beautify Lua to see the re-indented code.
  4. Save the result Copy the output or download it as script.lua.

Frequently asked questions

Does it run or check my Lua code?

No. It never executes code. It only scans for block keywords and quotes, and it reports unbalanced blocks or unterminated strings, but it is not a full syntax or type checker.

Which indent options exist?

2 spaces, 4 spaces or Tab. The default is 2 spaces.

Why is some text not re-indented?

Lines inside long strings and long comments, such as [[ ... ]] and --[[ ... ]], are kept exactly as written so their content is not altered.

Does it change line breaks or add spaces around operators?

No. Only the leading whitespace of each line is changed and runs of blank lines are kept as empty lines. The output ends with a single newline.

Are while and for loops handled?

They open with do, which is a tracked block keyword, and close with end, so their bodies are indented correctly.