Friday, January 5, 2007

Free online JavaScript formatter

[This was originally posted at http://timstall.dotnetdevelopersjournal.com/free_online_javascript_formatter.htm]

Sometimes you'll see JavaScript in what appears to be a garbled mess - no spaces, comments, or line breaks. This may be because JavaScript is transmitted over the wire, therefore it's faster performance to omit all those things that are unnecessary to the end user. However, they're great for the developer trying to read someone else's JavaScript. Hence, the need to format JavaScript.

There are several free formatters out there. Criteria I'm interested in is: (1) Accuracy, (2) Convenience - ideally an online tool as opposed to something I need to download, (3) Cost - ideally it'd be free, and (4) Length - I'd want it to be able to format large scripts, not just some 5 line demo.

There seems to be a lot to choose from: http://www.google.com/search?hl=en&q=JavaScript+formatter

Currently I'm looking at: http://www.jwmdev.tzo.com:8080/resources/js-tools/index.html

I'm also finding the NotePadd++ language feature helpful with this because it (1) color highlights JavaScript, and (2) match thes parenthesis and brackets for you (including nesting), making it very easy for you to format it yourself as you run through what the code actually does.

No comments:

Post a Comment