Lua Prettier - Format, Beautify and Validate Lua Online
Lua turns up wherever a program needs a small scripting language bolted onto something bigger: Neovim init.lua configs, Roblox and LÖVE 2D game code, World of Warcraft addons, Redis EVAL scripts, OpenResty and nginx request handlers, Wireshark dissectors, Garry's Mod servers and embedded firmware. Because it usually arrives as a snippet pasted from a forum post, a wiki, a chat message or a game console, it also arrives with whatever indentation the last four people used. This Lua formatter rewrites it into one consistent style.
Rather than nudging end keywords around with regular expressions, the tool parses your source into a real abstract syntax tree and prints it again from scratch. That distinction matters more in Lua than in most languages, because a brace-counting beautifier has no braces to count - and a [[long string]] or a --[==[ block comment ]==] full of Lua-looking text will defeat it entirely.
What it understands
The full grammar, across dialects: every block form from do…end through repeat…until and both flavours of for; every function form including the colon sugar in function obj:method() with its implicit self; table constructors mixing array parts, key = value pairs and computed [expr] = value keys; call sugar such as require "socket" and setmetatable{…}; varargs, multiple assignment and multiple return values; and the operators that make Lua Lua - .. for concatenation, ~= for inequality, # for length and the word operators and, or and not.
Newer syntax is covered too: goto and ::label:: from 5.2, integer division // and the bitwise operators from 5.3, and the local x <const> attribute from 5.4. Pick a dialect older than your code and you get a message naming the exact construct and the version it needs, instead of a bewildering token error.
Beyond indentation
Expand mode rebuilds structure from minified, packed or single-line Lua, which is the fastest way to make an obfuscated addon or a config blob reviewable. Compact mode does the reverse, keeping statements on one line for a slide, a chat message or a single-line EVAL fixture. Diff mode lists every line the formatter would touch, and Compare mode renders the same file under two presets side by side - useful for settling whether a team moves from the 2-space community style guide to StyLua's 4-space default.
Validate mode answers "is this even valid Lua?" and does it better than the interpreter does. Lua's own diagnostic for a missing end points at the end of the file, which is the least useful place to look; this tool replays the block openers and tells you the line where the unclosed function or if actually started.
Style options that settle arguments
Four presets cover the common house styles - StyLua's default, the community style guide, Roblox/Luau and a typical Neovim config - or you can set indentation, print width, quote preference, semicolon handling and table layout yourself. Tables can auto-fit, always expand or preserve your own line breaks, with an optional trailing separator and column-aligned = signs. The tool also emits the matching stylua.toml and .editorconfig block so the same style can be enforced in CI.
Alongside the formatted source you get a function outline drawn from the parsed tree, a de-duplicated list of required modules, and a report of identifiers that resolve to globals rather than locals - a classic Lua footgun, flagged as advice and never rewritten on your behalf.
(f()) are kept, because dropping them would truncate a multi-value call to a single value.Private by construction
The parser and printer are JavaScript that runs inside your own browser tab. Nothing is uploaded, nothing is logged and no network request is made after the page loads, so pasting a script that happens to carry an internal hostname, a server address or an API key does not put it anywhere. Files up to 2 MB can be dropped straight onto the editor.