Here’s a structured, useful guide to decompiling Lua bytecode ( .luac files).
1. Understand What a .luac File Is
.luac = compiled Lua script (bytecode). Generated by luac compiler or string.dump() . Not human-readable; contains platform-agnostic instructions for Lua VM.
2. Prerequisites: Know Your Lua Version Lua bytecode is version-specific (e.g., 5.1, 5.2, 5.3, 5.4, LuaJIT). Decompilers must match the version. Detect version : file yourfile.luac decompile luac
Or inspect first few bytes (hex):
1b 4c 75 61 → \x1bLua Byte 5 = version ( 0x51 = Lua 5.1, 0x52 = 5.2, 0x53 = 5.3, 0x54 = 5.4)
3. Decompilation Tools (by Lua version) Lua 5.1 (most common) | Tool | Type | Notes | |------|------|-------| | unluac | Java | Best for 5.1, open-source | | luadec | C++ | Fork of unluac, works well | | LuaDec51 | Python | Older but reliable | Lua 5.2 – 5.4 | Tool | Type | Notes | |------|------|-------| | unluac | Java | Supports 5.2–5.4 | | luadec (fork) | C++ | 5.2–5.4 support limited | | lua-lz | Python | Handles compressed chunks | LuaJIT ( .ljbc or .luac from LuaJIT) | Tool | Type | Notes | |------|------|-------| | LuaJIT-decompiler | Python | Very limited; mostly recovery of constants/flow | | ravi | C | Partial support | | luajit-decomp | Lua | Experimental | Here’s a structured, useful guide to decompiling Lua
⚠️ LuaJIT bytecode is hard to decompile (no perfect public tool).
4. Step-by-Step: Decompile with unluac (Recommended) Install : # Download latest unluac.jar wget https://github.com/HansWessels/unluac/releases/download/v2022.10.5/unluac20221005.jar
Decompile : java -jar unluac20221005.jar input.luac > output.lua Generated by luac compiler or string
Handle multiple chunks : java -jar unluac20221005.jar --rawstring input.luac > out.lua
5. Decompile with luadec git clone https://github.com/viruscamp/luadec cd luadec git submodule update --init --recursive make LUAVER=5.1