2

I saw an interesting js file in a website, but i cannot read it because it is minimized. Is there any service or method to convert it to a readable file?

The minimized js file is similar to the compiled output from Google Closure Compiler.

Xiaolong
  • 239
  • 1
  • 3
  • 12
  • Even if ran it through a "beautifier" script which would restore line breaks/indentation, all the variable/object names will have been mangled into minimized format and can NOT be restored. you'll end up with 'var a,b,c' instead of 'var this,that,whatever' – Marc B Jul 20 '11 at 14:54
  • This post answers the same question. http://stackoverflow.com/questions/1387810/is-there-such-a-thing-as-a-javascript-deminifier-deobfuscator – Sandeep Bhat Jul 20 '11 at 14:57
  • JS beautifer is enough for my requirement. But it seems google compiler also change the name of local variables, I just realize. – Xiaolong Jul 20 '11 at 15:03
  • 1
    @Xiaolong, most minifiers will change the name of local variables in order to reduce code size. The "Advanced Mode" of the closure compiler will also do a lot of optimizations. It looks like your script is minified with "Simple Mode", otherwise it won't be readable even passing through a beautifier. – Stephen Chung Jul 21 '11 at 05:45
  • 1
    I wish some of the beautifiers would regenerate variables as ranom unique strings, so that at least you could do a find/replace once you have reverse engineered a variable/function name. Doing a find and replace on "a" and "b" is not very effective :( – Ryan Wheale Oct 06 '12 at 17:58

2 Answers2

9

You can use http://jsbeautifier.org

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

There is also a similar feature provided by UglifyJs which has an option for beautifying the code:

Alex Objelean
  • 3,893
  • 2
  • 27
  • 36