Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including njsmin with all npm packages installed. Try it out:

var njsmin = require("njsmin")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

njsmin v1.0.3

A node.js module for javascript minification


This is a node.js module for minimizing javascript (jsmin for short).

It was originally written by Doug Crockford (, was ported to javascript by Franck Marcia (, which in turn was ported to node.js by Peteris Krumins (

The module exports 'jsmin' function:

var jsmin = require('jsmin').jsmin;

The 'jsmin' function takes three arguments:

* input js code
* integer aggressiveness level (defaults to 2)
* optional comment to prepend to output (defaults to nothing)

The aggressiveness level can be 1, 2 or 3:

* 1 - keep original newlines in output
* 2 - original Crockford's algorithm - remove some newlines
* 3 - remove all newlines

Start the comments that you don't want to remove (as process of minification) with /*! ... */


var jsmin = require('./jsmin').jsmin;
var sys = require('sys');

sys.puts(jsmin('function    hello( a , b , c ) {   sys.log(a + b + c) }'))


'function hello(a,b,c){sys.log(a+b+c)}'

Command-line Usage

Installing globally (using npm's -g flag) will also install a command-line tool for using jsmin:


The input filename should be the last argument. If you don't specify it, input will be read from STDIN instead.

Supported options:

--output FILENAME

    Specifies an output file for minified output. If not given, output
    will be written to STDOUT.

--level LEVEL

    Sets the aggressiveness level to be used.

--comment COMMENT

    Sets a comment to be prepended to the output.


    If provided and an input filename was provided (rather than using
    STDIN), output will be written to the same file input was read from.

Have fun jsminning!

Sincerely, Peteris Krumins


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free