Tools

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

Lua Script Compressor & Shrinker

Paste Lua scripts and instantly remove unnecessary whitespace, comments, and formatting to shrink file size

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

Paste any Lua script and strip out comments, extra whitespace, and blank lines in one click — the output stays functionally identical but loads faster and takes up less space. It handles single-line comments, block comments, long strings ([[...]], [=[...]=]), and every operator from Lua 5.1 through 5.4 without breaking string contents. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste Lua Code
→
Tokenize & Strip
→
Minified Output

The compressor tokenizes your Lua source into keywords, identifiers, strings, numbers, and operators. It throws out every comment and whitespace token, then reassembles the remaining tokens — inserting a single space only where two adjacent words would otherwise merge. Strings (including long strings with level markers) pass through untouched.

Examples

Stripping comments from a game script

You’ve got a Roblox module with inline docs everywhere.

INPUT
-- Player health module local Health = {} -- Set starting HP function Health.init(player) player.hp = 100 -- default player.alive = true end -- Reduce HP by amount function Health.damage(player, amt) player.hp = player.hp - amt if player.hp <= 0 then player.alive = false end end return Health
OUTPUT
local Health={}function Health.init(player)player.hp=100 player.alive=true end function Health.damage(player,amt)player.hp=player.hp-amt if player.hp<=0 then player.alive=false end end return Health

Collapsing a config file with block comments

Config files tend to be heavy on explanation, light on actual code.

INPUT
--[[ Server configuration Last updated: 2024-11-03 ]] local cfg = { port = 8080, host = "0.0.0.0", max_conn = 256, timeout = 30, }
OUTPUT
local cfg={port=8080,host="0.0.0.0",max_conn=256,timeout=30,}

Minifying a utility library with long strings

Long strings should survive compression completely intact — the compressor knows not to touch them.

INPUT
local template = [=[ Hello, {name}! Welcome to {place}. ]=] -- render the template function render(data) local out = template for k, v in pairs(data) do out = out:gsub( "{" .. k .. "}", v ) end return out end
OUTPUT
local template=[=[ Hello, {name}! Welcome to {place}. ]=]function render(data)local out=template for k,v in pairs(data)do out=out:gsub("{"..k.."}",v)end return out end

Who Uses This

🎮 Game Developers

Shrink Lua mods for Roblox, Garry’s Mod, or WoW addons before distribution.

🔧 Embedded Engineers

Fit scripts into tight flash memory on IoT devices running NodeMCU or eLua.

🌐 Backend Developers

Minify OpenResty/Nginx Lua scripts to cut response latency on edge servers.

📦 Package Authors

Ship smaller LuaRocks packages by stripping dev comments before publishing.

Common Mistakes

Compressing code that uses debug info at runtime

If your script calls debug.getinfo() and relies on line numbers or source names, compressed single-line output will shift all those values. Test runtime debugging behavior after compression.

Expecting variable renaming

This is a compressor, not an obfuscator. It won’t shorten playerHealth to a. If you need variable renaming, you’ll want a separate minifier pass — this tool only removes dead characters.

Losing the original source

Always keep your readable, commented version in version control. Compressed Lua is a build artifact — not something you should edit directly. Treat it like a compiled binary.

Technical Details

Frequently Asked Questions

Will compressed Lua code run the same as the original?

Yes. The compressor only removes comments and unnecessary whitespace. It doesn’t touch your logic, variable names, or string contents. The output is functionally identical to the input.

Does it work with Roblox Luau scripts?

It handles standard Lua syntax that overlaps with Luau. Basic Roblox scripts compress fine. However, Luau-specific syntax like type annotations or continue may not be recognized, so test your output before deploying.

How much smaller will my Lua file get?

Depends on how much whitespace and how many comments you have. Heavily documented scripts drop 40–60%. Already tight code might only shrink 10–15%. The stats bar shows you the exact reduction after each compression.

Is my code uploaded to a server?

No. Everything happens in your browser using JavaScript. Your Lua source never leaves your machine. Disconnect from the internet and it still works — that’s how you know nothing is being sent anywhere.

Can I compress multiple Lua files at once?

The tool handles one script at a time. For batch processing, you’d want a CLI tool like luamin or a build script. But for quick one-off compressions — pasting a file, grabbing the output — this is faster than setting up a toolchain.

Share: