I have a javascript file where all the line breaks and spacing has been removed, so the whole thing is on a single line. I’m looking for a utility that will add back in line breaks and indents to turn this into something human-readable, but not having much luck.
This issue in particular deals with javascript, but I will probably run into the same issue in the future with different languages; a tool that handles multiple languages would be preferred
For example, when given this
var h=Ext.util,j=Ext.each,g=true,i=false;h.Observable=function(){var k=this,l=k.events;if(k.listeners){k.on(k.listeners);delete k.listeners}k.events=l||{}};//etc etc
The tool should reformat it like this
var h = Ext.util, j = Ext.each, g = true, i = false;
h.Observable = function(){
var k = this, l = k.events;
if (k.listeners){
k.on(k.listeners);
delete k.listeners
}
k.events = l || {}
};
//etc etc
Thanks for the help
You may be interested in either jsBeautifier or jsFiddle‘s “Tidy Up” functionality.