1

How can I automatically format JavaScript properly?

As an example, this:

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

Should become:

(function(){
    (function(){
        alert('whatever')
    })()
})()
4
  • jsfiddle.net has a "tidyup" option - maybe it's open source based? Commented Apr 28, 2012 at 19:50
  • Have you tried jsbeautifier? Commented Apr 28, 2012 at 19:50
  • @Cameron turns out that's the one that jsfiddle uses Commented Apr 28, 2012 at 19:51
  • 2
    possible duplicate of Javascript Beautifier Commented Apr 28, 2012 at 19:52

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Python based? The one I saw is written in Javascript.
2

Try http://jsbeautifier.org/ - it's the same one used by jsfiddle.net on their "Tidy Up" button where you can try it out.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.