November 4th 2018

Unmangle your javascript variables

There are many tools you can find for unminifying javascript code. However, most of these tools just add proper formatting and call it a day. Considering many minifiers mangle local identifiers to one or two characters and reuse those identifiers frequently, this can result in some code that is still quite painful to read. I think we can do better.

I've created this online tool to not only format code (using prettier), but also go one step further by marking global variables and renaming mangled variables to be globally unique. It does this by renaming each variable to its type and the line number where it was defined (e.g. let let99_ = 10; if defined on line 99). The underscore helps differentiate let 9_ vs let 99_ when searching. Unmangling as a module vs script will determine whether top-level variable definitions are unmangled or not.

Give it a shot below or use the full-screen version here. If you think there's a better way to do this, found a bug, or think a feature would be easy to add, send a comment or pull-request my way!

unmangle as a