How can I automatically format JavaScript?
As an example:
(function(){(function(){alert('whatever')})()})()
It should become:
(function(){ (function(){ alert('whatever') })() })()
There is jsbeautifier , you can find github source code .
Try http://jsbeautifier.org/ - it is the same as jsfiddle.net used on the "Tidy Up" button, where you can try.