Search code examples
javascriptindentationpretty-print

Properly formatting JavaScript in JavaScript


How can I automatically format JavaScript properly?

As an example, this:

(function(){(function(){alert('whatever')})()})()

Should become:

(function(){
    (function(){
        alert('whatever')
    })()
})()

Solution

  • There is the jsbeautifier, you can find the source code at github.