Lua Script Prettifier & Indenter
Paste messy Lua scripts to prettify with proper indentation and consistent formatting
Paste messy or minified Lua code, click Beautify, and get clean indentation for every function/end, if/then/end, and for/do/end block. The Minify button does the opposite — strips whitespace down to a single compact line.
And everything runs in your browser. Nothing gets uploaded.
How It Works
The formatter splits your code line by line, identifies block-opening keywords like function, do, then, and repeat, then tracks depth as it hits closing keywords like end, until, and elseif. It skips over strings and comments so nothing inside quotes throws off the indentation. The result gets syntax highlighting on top — keywords, strings, numbers, and comments each get their own color.
Examples
Minified Roblox Script Cleanup
Someone shared a minified Roblox Lua script. You need to read what it actually does.
local function greet(name) if name then print("Hello, "..name) else print("Hello, world") end end greet("Lua")
local function greet(name)
if name then
print("Hello, "..name)
else
print("Hello, world")
end
end
greet("Lua")
Nested Loop with Table Constructor
A config file with loops and tables mashed together on minimal lines.
local t={} for i=1,10 do for j=1,5 do t[#t+1]={x=i,y=j} end end return t
local t = {}
for i = 1, 10 do
for j = 1, 5 do
t[#t + 1] = {x = i, y = j}
end
end
return t
Messy Game Mod with Mixed Indentation
A WoW addon file where half the lines use tabs and the other half use 3 spaces. Beautify normalizes everything.
function OnLoad()
local hp=UnitHealth("player")
if hp<50 then
print("Low health!")
elseif hp<80 then
print("Watch out")
else
print("Fine")
end
end
function OnLoad()
local hp = UnitHealth("player")
if hp < 50 then
print("Low health!")
elseif hp < 80 then
print("Watch out")
else
print("Fine")
end
end
Who Uses This
Cleaning up Roblox Studio scripts and WoW addon Lua before committing to version control.
Formatting Lua configs for OpenResty, Redis, or NGINX scripting modules.
Making homework submissions readable before turning in Lua programming assignments.
Quickly formatting third-party Lua to scan for logic errors or security issues.
Common Mistakes
end
If your function or if block is missing an end, the formatter will keep increasing indent forever. The output looks like a staircase going right. Count your block openers and closers — they should match.
end inside a string literal
The word "end" inside a quoted string won't confuse this formatter — it skips string contents. But if your string spans multiple lines with [[...]] syntax and has unbalanced brackets, things can get weird. Double-check long strings.
The formatter only touches whitespace. It won't catch a typo in a variable name or fix a missing then after an if. If the output looks wrong structurally, the bug is in your code, not the formatter.
Technical Details
- Processing: 100% client-side JavaScript — nothing leaves your browser
- Lua Support: All Lua 5.1 through 5.4 syntax including goto, long strings, and long comments
- Indent Options: 2 spaces, 4 spaces, or tabs
- Browser Support: Chrome, Firefox, Safari, Edge
- Output: Syntax-highlighted preview with copy and
.luadownload
Frequently Asked Questions
What does a Lua formatter do?
It takes Lua source code — usually messy, minified, or inconsistently indented — and rebuilds the whitespace so every block lines up correctly. Your actual code stays identical. Only the spacing changes.
Does it work with Roblox Luau scripts?
Standard Lua syntax formats perfectly. Luau-specific features like type annotations (: string) won't break the formatter, but it treats them as regular code rather than special syntax. For plain indentation cleanup, it works great on Roblox scripts.
Will formatting change how my Lua script runs?
No. Whitespace and indentation have zero effect on Lua execution. The formatter doesn't rename anything, reorder statements, or touch string contents. Your script behaves exactly the same before and after.
Is there a file size limit?
There's no hard limit since it runs in your browser. Scripts under 100KB format instantly. Larger files — say 500KB or more — might take a second or two depending on your machine. If your browser tab freezes on a massive file, try splitting it into smaller chunks first.
Can I use tabs instead of spaces for indentation?
Yes. Pick "Tab" from the indent dropdown before clicking Beautify. The formatter defaults to 4 spaces, but tabs and 2 spaces are both available. Whatever you choose applies to the entire output consistently.