Properly formatting JavaScript in JavaScript
Asked Answered
B

2

1

How can I automatically format JavaScript properly?

As an example, this:

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

Should become:

(function(){
    (function(){
        alert('whatever')
    })()
})()
Basophil answered 28/4, 2012 at 19:48 Comment(4)
jsfiddle.net has a "tidyup" option - maybe it's open source based?Bridie
Have you tried jsbeautifier?Bernice
@Bernice turns out that's the one that jsfiddle usesBridie
possible duplicate of Javascript BeautifierControvert
E
2

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

Eustasius answered 28/4, 2012 at 19:50 Comment(1)
Python based? The one I saw is written in Javascript.Bridie
B
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.

Bridie answered 28/4, 2012 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.