Program or text editor to format existing HTML code

I need to modify a chunk of HTML code that was exported from another program. This code was never intended to be read by human eyes, so while it is technically error-free (tags properly ordered and closed, etc.), the formatting leaves much to desired. One line in particular is 16,548 characters long without a line break. You can see where this would be annoying to work with.

I’m looking for a program that will format this code to be more easily readable. It can either modify the file directly, or allow me to paste the contents into the program for formatting. Proper indenting would be wonderful, but anything that adds line breaks between tags at reasonable intervals would suit my purposes just fine. I’m hoping someone has had this same problem and has written an application specifically to solve it…this is just the sort of thing I’m usually good at googling up freeware for, but for whatever reason this one eludes me.

I presume I could do something like this with emacs, vi or the like, but I never learned either (yeah, I know, I’ll turn in my coder card later) and I don’t have time right now to learn a complex editor. That said, if there’s a built-in function that does this that’s relatively easy to apply, I’m game.

If there’s nothing out there specifically for this purpose, I can write a macro to throw in a line break after every end tag, but I’m hoping for something a little more…elegant than that. Anyone have any suggestions?

if you want to do line wrap, Firefox’s View -> Wrap long lines will already handle this for you, at least for viewing. Whether or not you can then copy-paste the nicely wrapped text I am not sure.

This thread browser addons - Is it possible to view HTML source auto-formatted in Firefox - Super User brings up a Firefox plugin that allegedly can prettyprint html and javascript. Further, if you google for “prettyprint html”, here, Google, you will see various suggestions, some of them allegedly online available as public service.

Just use HTML Tidy.

It’ll work as a filter, so you can easily pipe it to your favorite editor, or whatever suits your fancy.

Sweet, that’s exactly what I need. Even better, a bit of googling turned up a GUI for it, so you don’t have to mess with command line hibbity-hoo for every file (unless you’re o’ of them *nix types who prefer it that way ;)).

Many thanks!

Dreamweaver would do it. But not for free, of course.