Lua Minifier

Transform text and structured data locally in your browser.

What the minifier does

Paste Lua source and click Run. The code is split into real Lua tokens (names, numbers, strings, long brackets, operators and comments), comments are dropped, and the tokens are joined back with a space only where Lua needs one to keep two tokens apart. Variable names are not renamed, so error messages and stack traces still make sense.

-- comment
local function add(a, b)
  return a + b -- sum
end
print(add(1, 2))

becomes

local function add(a,b)return a+b end print(add(1,2))

What is preserved

When to minify Lua

Minifying helps when script size counts: embedding Lua in firmware or ESP8266/NodeMCU modules, sending scripts to Redis with EVAL, shipping mods with size limits, or pasting a script into a game console. For readable code, run it through the Lua formatter instead.

FAQ

Does it work with Luau (Roblox) code?

Yes for ordinary scripts, since Luau shares Lua's syntax. Luau-only operators such as += are kept as written, and type annotations pass through unchanged.

Will minified code run differently?

No. Only comments and insignificant whitespace are removed; the token sequence the Lua parser sees is the same.