🌙 Lua 代码压缩Lua Minifier
压缩 Lua 代码:删除 -- 单行注释和 --[[ ]] 块注释、去掉多余空白和换行,只在必要处(两个标识符或数字之间)保留一个空格。正确处理字符串和 [[ ]] 长字符串,不会破坏其中内容。数据在本地处理。Minify Lua code — remove -- line comments and --[[ ]] block comments, strip redundant whitespace and newlines, and keep a single space only where needed (between two identifiers or numbers). Strings and [[ ]] long strings are preserved exactly. Processed locally.
使用说明与常见问题How-to & FAQ
「Lua 代码压缩」是什么?What is the Lua Minifier tool?
压缩 Lua 代码:删除 -- 单行注释和 --[[ ]] 块注释、去掉多余空白和换行,只在必要处(两个标识符或数字之间)保留一个空格。正确处理字符串和 [[ ]] 长字符串,不会破坏其中内容。数据在本地处理。Minify Lua code — remove -- line comments and --[[ ]] block comments, strip redundant whitespace and newlines, and keep a single space only where needed (between two identifiers or numbers). Strings and [[ ]] long strings are preserved exactly. Processed locally.
如何使用「Lua 代码压缩」?How do I use the Lua Minifier tool?
在「Lua 代码压缩」中,把内容粘贴或输入到上方输入框,结果会实时显示在下方,点击「复制结果」即可复制。例如输入「x=1」,得到「x=1」。In the Lua Minifier: Paste or type into the input box; the result appears below instantly — click "Copy result" to copy it. Example: "x=1" → "x=1".
会破坏字符串里的内容吗?Will it damage string contents?
不会。工具会识别 '...'、"..." 和 [[ ... ]] 长字符串,原样保留其中的空格、换行和看起来像注释的 -- 文本,只压缩代码部分。No. It recognises '...', "..." and [[ ... ]] long strings and keeps their spaces, newlines and any -- that looks like a comment exactly as written, minifying only the code around them.
为什么有些地方保留了一个空格?Why is a single space kept in places?
Lua 靠空白区分相邻的关键字/名称/数字,例如 local x、return a、1 and 2。工具只在两个这类记号相邻时保留一个空格,其余空白和换行都删除。Lua needs whitespace to separate adjacent keywords, names and numbers, such as local x, return a and 1 and 2. The tool keeps a single space only between two such tokens and removes all other whitespace and newlines.
它会改变代码逻辑吗?Does it change what the code does?
不会。它只删除注释和多余空白,不重命名变量、不改写语句,所以行为与原代码完全一致,但不含源码级调试信息(行号会变)。No. It only removes comments and redundant whitespace — it does not rename variables or rewrite statements — so behaviour is identical, though source-level line numbers change.
支持哪种 Lua 版本?Which Lua version does it support?
适用于 Lua 5.1–5.4 的通用语法,包括 --[[ ]] 块注释、长括号 [==[ ]==] 和转义字符串。它是基于词法的压缩器,不做完整语法分析,因此不校验代码是否正确。It works with the common syntax of Lua 5.1–5.4, including --[[ ]] block comments, long brackets [==[ ]==] and escaped strings. It is a lexical minifier, not a full parser, so it does not check whether the code is valid.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「Lua 代码压缩」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The Lua Minifier runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「Lua 代码压缩」免费吗?需要注册吗?Is the Lua Minifier free? Do I need an account?
「Lua 代码压缩」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Lua Minifier is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.