Is there such thing as Javascript Tidy?
November 12, 2005 8:19 AM Subscribe
Is there a utility out there that does for Javascript code what HTML Tidy does for (X)HTML? I've started working with a bunch of Javascript code that's just messy as all hell, and would love to preprocess it into something a bit neater before buckling down and getting to work. Something online (similar to this online HTML Tidy interface) would be perfect, something *nix command-line would be good as well, and I guess an app that handled the cleanup would be fine (OS X preferred). This might be a no-brainer, but I've searched high and low without results...
Best answer: for programming languages, this kind of thing is called a pretty printer, but will only reformat, not detect errors. try here. via google javascript pretty printer
posted by andrew cooke at 8:33 AM on November 12, 2005
posted by andrew cooke at 8:33 AM on November 12, 2005
Response by poster: Andrew, that prettyprinter.de link is great; in my ten minutes of testing just now, its heuristics create some mildly weird output at times, but generally only because the JS that I'm throwing at it is really odd in places. It's perfect for the use I need right now... thanks!
posted by delfuego at 9:14 AM on November 12, 2005
posted by delfuego at 9:14 AM on November 12, 2005
GNU Indent might be suitable for reformatting basic JavaScript, though I don't know how well it would deal with some of the more esoteric features of the language that aren't shared with C.
posted by letourneau at 12:05 PM on November 12, 2005
posted by letourneau at 12:05 PM on November 12, 2005
ISTR that the Venkman debugger for Mozilla had a JS reformatter in it.
posted by i_am_joe's_spleen at 12:13 PM on November 12, 2005
posted by i_am_joe's_spleen at 12:13 PM on November 12, 2005
This thread is closed to new comments.
posted by mnology at 8:32 AM on November 12, 2005