Lua Minifier
Transform text and structured data locally in your browser.
Transform text and structured data locally in your browser.
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))
[[...]] and [==[...]==], byte for byte.local function), after numbers before a dot so 1 ..x stays a concatenation, and between operators that would otherwise merge into a different one (- -x must not become a -- comment).#! shebang line at the top is removed, because it is only meaningful when the file is executed directly.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.
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.
No. Only comments and insignificant whitespace are removed; the token sequence the Lua parser sees is the same.