You just got a JS file to work with that's either been minified or really badly indented. What do you do? If you're on OS X or a Linux-based system, fire up Terminal and fire off the
The Quick and dirty way to indent JS files article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
indent command:
indent < badly-indented.js > beautiful.js
Since indent is actually meant for C, it may not be perfect but the result should be much easier to read than the original if you're trying to figure out what's going on in the script.
The Quick and dirty way to indent JS files article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

Aptana (http://www.aptana.com/) has a great format feature as well as real-time JavaSCript syntax checking and it’s free.
Also, if you have Flash 8, you can copy JS into the actions panal and hit the autoformat button and get some pleasing results. Flash CS3 has a horribly broken autoformat, so I don’t recommend EVER using it.
And if you have TextMate handy, then JavaScript bundle comes with Reformat Document command.
Pretty sure Dreamweaver can do this too – not as clean as a comand-shell call but gets the same outcome