Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


A Lua minifier written in JavaScript

Subscribe to updates I use luamin

Statistics on luamin

Number of watchers on Github 75
Number of open issues 16
Average time to close an issue 4 months
Main language JavaScript
Average time to merge a PR about 5 hours
Open pull requests 1+
Closed pull requests 8+
Last commit about 3 years ago
Repo Created about 7 years ago
Repo Last Updated about 2 years ago
Size 173 KB
Organization / Authormathiasbynens
Page Updated
Do you use luamin? Leave a review!
View open issues (16)
View luamin activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating luamin for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

luamin, a Lua minifier written in JavaScript

Build status Dependency status

luamin uses the excellent luaparse library to parse Lua code into an Abstract Syntax Tree. Based on that AST, luamin then generates a (hopefully) more compact yet semantically equivalent Lua program. Heres an online demo.

luamin was inspired by the LuaMinify and Esmangle projects.

Feel free to fork if you see possible improvements!

Installation and usage

Via npm:

npm install luamin

Via Bower:

bower install luamin

Via Component:

component install mathiasbynens/luamin

In a browser:

<script src="luamin.js"></script>

In Narwhal, Node.js, and RingoJS:

var luamin = require('luamin');

In Rhino:


Using an AMD loader like RequireJS:

    'paths': {
      'luamin': 'path/to/luamin'
  function(luamin) {

Usage example:

var luaCode = 'a = ((1 + 2) - 3) * (4 / (5 ^ 6)) -- foo';
luamin.minify(luaCode); // 'a=(1+2-3)*4/5^6'

// `minify` also accepts luaparse-compatible ASTs as its argument:
var ast = luaparse.parse(luaCode, { 'scope': true });
luamin.minify(ast); // 'a=(1+2-3)*4/5^6'

Using the luamin binary

To use the luamin binary in your shell, simply install luamin globally using npm:

npm install -g luamin

After that you will be able to minify Lua scripts from the command line:

$ luamin -c 'a = ((1 + 2) - 3) * (4 / (5 ^ 6))'
$ luamin -f foo.lua

See luamin --help for the full list of options.


luamin has been tested in at least Chrome 25-48, Firefox 3-44, Safari 4-9, Opera 10-35, IE 6-11, Edge, Node.js v0.10.0v5, Narwhal 0.3.2, RingoJS 0.8-0.11, PhantomJS 1.9.0, and Rhino 1.7.6.

Unit tests & code coverage

After cloning this repository, run npm install to install the dependencies needed for luamin development and testing. You may want to install Istanbul globally using npm install istanbul -g.

Once thats done, you can run the unit tests in Node using npm test or node tests/tests.js. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use grunt test.

To generate the code coverage report, use grunt cover.


Mathias Bynens


luamin is available under the MIT license.

luamin open issues Ask a question     (View All Issues)
  • over 3 years ifStatement is not right with logical
  • over 3 years Aggressive parentheses removal breaks sources.
  • almost 4 years Argument handling in non-TTY context appears broken
  • about 4 years Scope/variable context support
  • almost 5 years (expr) and true or false -> not not (expr)
  • almost 5 years Optimize if not <cond> then <a> else <b> end -> if <cond> then <b> else <a> end
  • almost 5 years Aggressive Lua minifier
  • over 5 years Setting local right after declaring it could be optimized
  • almost 7 years Optimize strings
  • about 7 years Look for performance improvements
luamin open pull requests (View All Pulls)
  • fixed issue with select() when varargs are passed
luamin list of languages used
Other projects in JavaScript