I have made the mistake of not indenting the HTML tags on a page that slowly grew to over 500 lines of dense HTML. I have looked for a tool to fix the indentation, but what I have found so far seem to insist on doing additional formatting, and I really don't need those 500 lines to become 1000 because big bunches of small tags get one line per tag.

Any suggestions for a tool to do the job?

2 Answers 2


You didn't tell us which tools you tried so far, but the first that comes to my mind is HTML Tidy: http://tidy.sourceforge.net/

  • Sorry, yes I tried Tidy, though only with a webpage interface. I can't get it to not inject a bunch of lineshifts, it's quite bad with tables, two lines per td element is way too much. It also feature messing up the JavaScript and CSS tab indentation. Jan 19, 2011 at 21:52
  • 1
    @ebus Tidy has a LOT of configuration options, I recommend you try it in htmlkit.com where it can be configured via a nice GUI Jan 19, 2011 at 23:11

The JetBrains IDEs allow you to reformat your code based on a set of rules, so you can get as detailed or as simple as you want. If this is a one-time thing, you could always use the trial copy of whichever one is most appropriate for you to reformat your code.

WebStorm is probably your best bet, although if you're developing your web applications with PHP, Ruby on Rails, or a few other languages, they have you covered there, too.

  • Seems like it may be able to do the job, gotta experiment a bit more to get it just right though. Hadn't imagined this would be so complicated. Performance is pretty bad when working with a 100kB file by the way. Jan 20, 2011 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.