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.)
In Firefox, SpiderMonkey and Rhino you can wrap any code into an anonymous function and call its
toSource
method, which will give you a nicely formatted source of the function.toSource
also strips comments.E. g.:
Will be converted to a string:
P. S.: It's not an "online tool", but all questions about general beautifying techniques are closed as duplicates of this one.
Similar to Stone's answer, but for Windows/.NET developers:
If you have Visual Studio and ReSharper - An easy alternative for formatting Javascript is:
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)
http://unminify.appspot.com/ Great tools for unminify javascript and json
If you have a Mac and TextMate - An easy alternative for formatting Javascript is:
Most of the IDEs also offer auto-formatting features. For example in NetBeans, just press CTRL+K.