35+ Tools to Minify Code (JavaScript, CSS & HTML)

Minification (in programming) is the process of compressing code from the original size to the smallest size, without affecting the operation of the code. It involves removing white-spaces, new lines, comments and modifying some unnecessary characters. Depending on the code, the process can reduce the original size anywhere from 5 to 90 percent.

We have gathered some automated tools that can help you reduce the size of your code without putting much effort. The final output will allow you to save some resources on the web server. We’ve split these tools according to the programming language. Have a look.

Minify JavaScript

JavaScript

Compressed JavaScript files are ideal for the production environment. You lose human readability but at the time, you conserve bandwidth.

Majority of reduction is achieved by eliminating comments and extra white space. Whereas, joining consecutive var declaration, optimizing if statements and converting array to objects can save 10% of the size.

Overall, the listed tool will help you to reduce the number of HTTP requests, bandwidth consumption and provide quicker download time for your users.

JavaScript Minifier is a nice looking online tool with an API.

JScompress is an online tool powered by Node.js and UglifyJS. Either copy/paste the code or upload the file for compression.

JSmini is Dan’s tool to compress your pretty well written JS code.

Koala is a GUI application for Sass, Less, JS minification, Compass, and CoffeeScript compilation. It supports Windows, Mac, and Linux.

Uglify.js (standalone command line tool) is a JavaScript parser, compressor, and decompressor.

rJSmin is JS minifier written in Python, based on the semantics of jsmin.c by Douglas Crockford.

Grunt is a command line tool that supports an extension for JS compression named grunt-contrib-uglify.

Read: 40 Useful JavaScript Frameworks for Developers

Minify CSS

CSS

CSS minification is a process of reducing CSS string/file size without altering the code functions. The process includes removing useless white spaces, line breaks, indentation characters, extra semi-colons, empty CSS declaration, unit with zero values, leading 0 (if float value is lower than 1) and stripping comments.

In order to achieve maximum reduction, RGB color values are converted to a shorter hexadecimal format, #BBCCDD are reduced to #BCD, none values are converted to 0 (where ever possible), and a few tools keep a single charset per CSS file eliminating all extra decelerations.

CSS Compressor allows you to minify CSS to make your website load faster. You can select from 4 levels of compression i.e. highest, high, standard and low.

CSS Minifier is simple, fast and quick web tool with an API.

Clean CSS is a well-tested node.js library for compressing CSS code.

CSSO has a usual compression technique and it can perform structural minimization of CSS files.

Coveloping is a web tool that gives you numerous manual options to compress the code. Either put a CSS file URL or paste the code.

CSSTidy is an open source CSS parser and optimizer, available as an executable file which can be controlled per command line and as PHP script.

Feedthebot is a quick web tool to compress CSS code, written by Patrick Sexton.

Read: Hilarious Puns on CSS

Minify HTML

HTML

Having compressed HTML files online could save you a lot of money on your server bills if you are hosting a very heavy bandwidth website. These compression tools will save space in HTML files by removing text line breaks, tab spaces, and replacing double spaces with single spaces without breaking the content structure.

HTMLcompressor is a small, fast and easy to use Java library that minifies HTML and XHTML code.

Text Fixer is on online compression tool that supports compression and decompression of HTML code.

Minify-HTML is an online tool (by GTmetrix) for compacting HTML code including any inline JavaScript and CSS contained in it.

Willpeavy allows you to minify HTML, XHTML and any JS or CSS included in your markup.

Kangax (beta) provides you numerous minify option while compressing your HTML code.

HTML minify is a node.js module that compresses HTML files with any JS and CSS.

HTMLMinifier is highly configurable, well tested, JavaScript-based compressor with lint-like capabilities.

Read: Useful HTML and CSS Frameworks For Web Designers

Miscellaneous Tools (Supports HTML/CSS/JavaScript)

code minified

Prepros is a cross-platform tool to compile Sass, Less, Compass, Jade, minify codes, automatic CSS prefixing and much more.

YUI Compressor is a free command line tool written in Java and relies on Rhino to tokenize the source JavaScript file.

Refresh-SF is a web interface to compress CSS and JavaScript. The tool uses HTML minifier, Clean-CSS and UglifyJS 2.

MinifyCode is a quick web tool to compress or decompress HTML, CSS, and JavaScript.

Microsoft Ajax Minifier allows you to improve the performance of the webpage by reducing the size of CSS and JS.

A NetBeans Plugin to minify CSS, HTML, and JS for quicker page load time.

Refresh-SF is a web interface to compress JavaScript or CSS. It uses Clean-CSS, HTML minifier and UglifyJS 2.

Yahoo Compressor is free software to decrease the size of JavaScript and CSS file.

HTMLCompressor is an online tool that safely reduces the size of HTML code, CSS, JavaScript plus PHP files.

Minifier is a simple command line tool for compressing CSS and JS without a big setup.

Webmini (Voralent product) is free software for compressing JavaScript and CSS file.

Smaller is an OS tool for compressing CSS, HTML, and JavaScript.

Ultraminifier is a free application for OS X which minifies JS and CSS with drag-drop.

AjaxminGui is a free Windows tool that minifies all JavaScript files in a folder and nested folder.

Recommended: 10+ Best Programming Software | for writing code

Update – For those who are asking for PHP minifier

Yes, there are some tools available to compress PHP code, but they don’t do much except stripping spaces and comments.

Since PHP is compiled into bytecode (like Perl and Ruby) and then interpreted on top of Virtual Machine, there would be no significant advantage [in terms of speed] of compressing code. However, you can always use bytecode cache (such as APC) to increase performance.

Hope this helps!

Written by
Varun Kumar

Varun Kumar is an experienced science and technology journalist interested in machines, AI, and space exploration. He received a Master's degree in computer science from Indraprastha University. To find out what his latest project is, feel free to directly email him at [email protected] 

View all articles
Leave a reply

1 comment
  • cssminifiers(dot)com is currently best minifier/un minifier. I am using this minifier for minifying my css files. Minify CSS code by removing useless white spaces, indentation characters, line breaks, newlines, empty CSS declarations, indentation, and comments.