Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to Unminify / Decompress JavaScript [closed]

Are there any command line scripts and/or online tools that can reverse the effects of minification similar to how Tidy can clean up horrific HTML?

(I'm specifically looking to unminify a minified JavaScript file, so variable renaming might still be an issue.)

like image 620
Andy Ford Avatar asked May 04 '09 21:05

Andy Ford


People also ask

How do I Unminify a JavaScript file?

You can't unminify a minified file. Minification is a desctructive operation and involves loss of information. For example, if you have a function with a descriptive name, after minifcation that name will be substitute with a meaningless one. There's no way to go back from this operation.

How do I minify JavaScript online?

Use your JS URL to compress. Click on the URL button, Enter URL and Submit. Users can also minify JS File by uploading the file. Minify JS Online works well on Windows, MAC, Linux, Chrome, Firefox, Edge, and Safari.


2 Answers

You can use this : http://jsbeautifier.org/ But it depends on the minify method you are using, this one only formats the code, it doesn't change variable names, nor uncompress base62 encoding.

edit: in fact it can unpack "packed" scripts (packed with Dean Edward's packer : http://dean.edwards.name/packer/)

like image 164
Fabien Ménager Avatar answered Oct 02 '22 06:10

Fabien Ménager


Chrome developer tools has this feature built-in. Bring up the developer tools (pressing F12 is one way), in the Sources tab, the bottom left bar has a set of icons. The "{}" icon is "Pretty print" and does this conversion on demand.

UPDATE: IE9 "F12 developer tools" also has a "Format JavaScript" feature in the Script tab under the Tools icon there. (see Tip #4 in F12 The best kept web debugging secret)

enter image description here

like image 41
Jon Adams Avatar answered Oct 02 '22 07:10

Jon Adams