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 html-minify with all npm packages installed. Try it out:

var htmlMinify = require("html-minify")

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

html-minify v0.3.2

minify html, and any CSS or JS included in your markup


Build Status Dependency Status

This is a node.js module that minimize HTML files with any CSS & JS. the css minify use cssmin,the html minify use the html-minifier


You can either download the plugin and unzip it into to your project folder or you can use npm to install the cssmin package.

npm -g i html-minify
    %> htmlminify one.html
    %> htmlminify -o one-min-utf8.html one-utf8.html //default charset is utf-8
    %> htmlminify -o one-min-gbk.html one-gbk.html -c gbk

how to use?see this:


The module exports the html-minify function, so you can use it with :

var htmlminify = require('html-minify');

The function htmlminify takes two arguments :

  • input : the html content you want to minimize.
  • linebreakpos : the number of characters before the end of the line. If empty, the output will have only one line.

Example :

var puts = require('util').puts,
fs = require('fs'),
var htmlminify = require('./html-minify');
var text = fs.readFileSync("/Any/Random/HTML.html", encoding='utf8');
var min = htmlminify(text);


  • 2013-07-08 minify js and css
  • 2013-07-03 change iconv to iconv-lite
  • 2013-06-26 fix utf-8 charset bug
  • 2013-05-31 cli support charset
  • 2013-05-30 first update


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