Is there such a thing as a javascript deminifier (

2019-01-08 17:56发布

This question is exactly the opposite of Which Javascript minifier (cruncher) does the same things that the one Google uses for its JS APIs?

I want to learn how google does it's loading so I can build my own with non-popular JS toolkits.

9条回答
女痞
3楼-- · 2019-01-08 18:10

To unminify js files, Unminify would be the best!

查看更多
冷血范
4楼-- · 2019-01-08 18:12

Uhhh, it would be impossible to restore variable names unless there was a mapping of minified -> original variable names available. Otherwise, I think the authors of that tool could win the Randi prize for psychic feats.

查看更多
贪生不怕死
5楼-- · 2019-01-08 18:13

See our SD ECMAScript Formatter for a tool that will nicely format code.

EDIT: If you want to reverse the renaming process you need something can rename the obfuscated names back to the originals.

This tool can technically do that: SD Thicket ECMAScript Obfuscator.

It does so by applying a renaming map over which you have precise control. Typically you implicitly construct such a map during the obfuscation process by choosing which names to obfuscate and which to preserve, and the obfuscator applies that map to produce the obfuscated code.

The Thicket obfuscator generates this map as side effect when you obfuscate in the form essentially of a set of pairs (originalname,obfuscatedname) for reference and debugging purposes.

Swapping elements gives the map (obfuscatedname,originalname). That inverted map can be applied by Thicket to recover the code with the original names, from the obfuscated code. And the Thicket obfuscator includes the Formatter to let you make it look nice again.

The catch to "reversing minification" (as you put it poorly, you are trying to reverse obfuscation), is that you need the map. Since people doing obfuscation don't give away the map, you, as a recipient of obfuscated code, have nothing to apply. A would-be pirate would have to reconstruct the map presumably by painful reverse engineering.

The "reversing" process also can't recover comments. They're gone forever.

This is all by design, so the real question is why are you looking to reverse obfuscation?

查看更多
贪生不怕死
6楼-- · 2019-01-08 18:13

Javascript minifier and Javascript Obfuscator are two different things.

Minifier - removes the comments, unnecessary whitespace and newlines from a program.

Obfuscator - make modifications to the program, changing the names of variables, functions, and members, making the program much harder to understand. Some obfuscators are quite aggressive in their modifications to code.

This Javascript Obfuscator will obfuscate your code.

If you want to deobfuscate your code, try Javascript Beautifier. It will deobfuscate if obfuscation is found and then beautify the code.

查看更多
Anthone
7楼-- · 2019-01-08 18:15

You will not be able to reconstruct method name or variable names. The best you can hope for is a simple JS code formater (like those previously mentioned), and then to go through the file method by method, line by line, working out what each part does.

Perhaps using a good JS refactoring tool would make this easier as well (being able to rename/document methods)

查看更多
登录 后发表回答