Javascript Compressor

Skip intro and go straight to the Compressor Tool!

This online compressor tool is a cut down version of the one I wrote for use on my own sites. Whereas there are other good compression tools out there I required one that had customised features to remove and add certain functions and other custom features such as keeping custom comments and removing debug statements. You can read more about the reasons for its creation on this blog article..

Unlike some of the other online compressor tools this version allows you to specify a list of function and objects that you can replace with minified versions. This allows you to reduce the size of commonly referenced functions and objects by specifing small names for them e.g replace addEvent with A. You can also insert a get function to replace calls to document.getElementById and also minify some global object references.

The best compression with this tool so far had a reduction of 72.29%

The details of this compression were:

Original Size: 24.41 KB Compressed Size: 6.76 KB Reduced by: 17.64 KB Compression Ratio: 72.29%

Strictly Software Javascript Compression Tool

Either upload a file to compress or paste the content into the input box. The maximum file size is 200KB.

In complex mode the compressor will try to rectify simple issues such as missing terminators and brackets when trying to format the code but to ensure the best possible compression make sure the code you input validates correctly and is properly formatted.

Enter the content to be compressed

Or select a file from your PC

Advanced Options

For more details about the following options please refer to the online documentation.


Simple mode will remove comments, space and minify functions but will not condense code whereas Complex mode will try to put each function or object on its own line and will try to auto-correct code to enable this. For instance it will add or remove terminators, combine variable declarations and add brackets.

If you have specific global functions that you wish to replace with smaller names then provide a list in the format [function:minified,function:minified] for example [getEl:G,addEvent:A] will replace all occurances of function calls to getEl and addEvent with G and A respectivley. You can replace up to 20 functions with this free tool.

If you have specific global objects that you wish to replace with smaller names then provide a list in the format [object:minified,object:minified] for example [Debugger:_d,System:_s] will replace all occurances of references to the objects Debugger and System with _d and _s respectivley. You can replace up to 20 functions with this free tool.

If selected this will add the following line of code to the file var _w=window,_n=navigator,_d=document and then replace any of those objects within the supplied code with the minified version.

If selected this will add a get function to replace any document.getElementById calls in your code and then replace any occurances of document.getElementById with the minified function name provided below.

The name of the minified function that will be added if the Add Get Function option has been selected.

If selected this will remove any functions called ShowDebug which should be added to your code during development to help debuging (e.g outputing messages to console) but removed on production servers to aid performance.

Post Comments

If you find any problems with the complex mode please try the simple mode option. If you have any severe problems that are not related to trying to compress incorrectly formatted code then please post details of the problem in the comment section of the related blog article.