JSBeautifier - De-minifier of Javascripts(video: 5:46)

I made a screencast on JSBeautifier - a tool that de-minifies Javascript. It covers using the online tool as well as how to install it as command line script and how to use it within Textmate.

Or, if you prefer to read, then read on...

To use the online version of the tool, go to jsbeautifier.org. Copy some minified Javascript and paste it into the large textarea on the left side of the screen and hit the button on the top labeled "Beautify JavaScript or HTML". Voila!

To install it as a command line tool, you'll want to go to their Github page and clone their repo

git clone https://github.com/einars/js-beautify.git

Then go into the js-beautify/python directory, and do

python setup.py install

This should install the js-beautify executable. Try executing js-beautify to see that it worked.

Textmate Integration

To use js-beautify inside of Textmate, first ensure js-beautify is in the PATH variable for the environment that's setup for Textmate. To do that, open up Preferences -> Advanced -> Shell Variables, and edit the PATH variable. You can do which js-beautify on your command line to find out where it was installed.

Now, paste some minified Javascript in a new Textmate window, use the Cmd+Opt+R shortcut to bring out the "Filter Through Command" dialog, and put js-beauify -i in the Command field. If the minified Javascript is the only thing in your window, then just select "Document" for the input and "Replace Document" for the output. Hit "Execute" and see it de-minify!

blog comments powered by Disqus