Lua Beautifier
Format Lua code with StyLua.
Lua Beautifier – Format Lua with StyLua
The Lua beautifier formats Lua code with StyLua, the opinionated Lua formatter used by Neovim plugins, Roblox projects, and game studios. It runs in your browser as WebAssembly, so formatting is instant and private.
What it formats
- Functions, local functions, and methods (
function Inventory:add(name, qty)). - Control flow:
if/elseif/else, numeric and genericfor,while, andrepeat ... until. - Tables, with long tables expanded one field per line and short ones kept inline.
- Strings, with consistent quote style, and long strings
[[...]]kept as written. - Comments, including block comments
--[[ ... ]].
Code written on a single line, like function f(a) if a then return 1 end end, is expanded into properly nested lines.
Options
- Indentation – 2 spaces, 4 spaces, or tabs.
- Quotes – prefer double or single quotes (switching when it avoids escapes), or always use one style.
- Line width – 80, 100, or 120 characters; longer calls and tables are wrapped.
Syntax errors
StyLua parses the full program before formatting. Missing end keywords, unbalanced parentheses, or invalid tokens produce an error message instead of broken output.
Where Lua is used
Lua is embedded everywhere: game engines like LÖVE, Defold, and Roblox (Luau), Neovim configuration, Redis scripts, NGINX/OpenResty, World of Warcraft add-ons, and many embedded devices. Consistently formatted scripts are easier to share and review across all of them.
Related tools
Shrink scripts with the Lua Minifier, format configuration data with the JSON Beautifier, or prepare YAML for game tooling with the YAML Beautifier.
Frequently Asked Questions
Does it support Luau (Roblox)?
StyLua supports Lua 5.1–5.4 syntax and common Luau syntax. Some Luau-only type annotations may not parse in this build; standard Lua always works.
Will formatting change how my script runs?
No. StyLua only changes whitespace, line breaks, quotes (when the string value is identical), and optional parentheses. The program behaves the same.
Why did my quotes change?
The default quote style prefers double quotes unless single quotes avoid escaping. Choose Keep or one of the Always options to control this.