views:

23212

answers:

3

Are there any 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 (like with compression or packing) should theoretically not be an issue.

+60  A: 

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/)

Fabien Ménager
+1 - I've used this method before, and jsbeautifier.org is an excellent service.
Daniel Lew
Thanks. This is exactly what I was looking for.
Andy Ford
did you mean base64 encoding? I've never heard of base62 encoding...
rmeador
Nope, I said base 62 : http://dean.edwards.name/packer/ and http://en.wikipedia.org/wiki/Base_62
Fabien Ménager
is there such a thing as a tool that "changes variable names" and is still aware of JS syntax to not break the code?
Jorge Vargas
would up this 10 times if i could. just saved me from a wasted day!
benlumley
Fantastic. I just solved my problem, then emailed the author of the framework with the exact fix.
Marcus Downing
+3  A: 

Can't you just use a javascript formatter (http://javascript.about.com/library/blformat.htm) ?

Janco
+1 for answer that also works. fabien just happened to reply first
Andy Ford
This only answer the "decompress" part of the question.
Jorge Vargas
A: 

As an alternative (since I didn't know about jsbeautifier.org until now), I have used a bookmarklet that reenabled the decode button in Dean Edward's Packer.

I found the instructions and bookmarklet here.

here is the bookmarklet (in case the site is down)

javascript:for%20(i=0;i<document.forms.length;++i)%20{for(j=0;j<document.forms[i].elements.length;++j){document.forms[i].elements[j].removeAttribute(%22readonly%22);document.forms[i].elements[j].removeAttribute(%22disabled%22);}}
fudgey