Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Lua Script Prettifier & Indenter

Paste messy Lua scripts to prettify with proper indentation and consistent formatting

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

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

Paste Lua Code
➔
Parse & Re-indent
➔
Syntax-Highlighted Output

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.

INPUT
local function greet(name) if name then print("Hello, "..name) else print("Hello, world") end end greet("Lua")
OUTPUT
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.

INPUT
local t={} for i=1,10 do for j=1,5 do t[#t+1]={x=i,y=j} end end return t
OUTPUT
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.

INPUT
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
OUTPUT
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

🎮 Game Developers

Cleaning up Roblox Studio scripts and WoW addon Lua before committing to version control.

💻 Embedded Engineers

Formatting Lua configs for OpenResty, Redis, or NGINX scripting modules.

🎓 Students

Making homework submissions readable before turning in Lua programming assignments.

🔍 Code Reviewers

Quickly formatting third-party Lua to scan for logic errors or security issues.

Common Mistakes

Forgetting a closing 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.

Using 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.

Expecting code logic fixes

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

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.

Share: