hindent - HTML reformatting/nesting utility
hindent [-fslcv] [-i num] [-t num] [file ...]
This utility takes one or more HTML files and reformats them by
properly indenting them for greater human readability. The new HTML
code is written to standard output, any errors go to standard error.
If no file is specified, hindent reads from standard input. If more
than one file is specified, each is taken in turn and all output is
concatenated (with no way to distinguish when one output ends and the
Without any options, hindent simply varies the amount of whitespace at
the beginning of each line of input - no lines are added or subtracted
from the HTML code. This means that it generates output that should
draw the same on all browsers as the input HTML. If the -s or -f
options are used, the resulting HTML may not draw exactly the same any
more. It is important that you keep your original HTML data around,
just in case!
This version of hindent understands all container tags defined in the
HTML 3.2 standard.
-c Case. Forces all tags to lowercase. By default, hindent forces
all tags to uppercase.
-f Flow. Prints just tags without any data between the tags.
Damages the HTML in a big way, so save a copy of your original
HTML. This option helps you follow the HTML code flow visually.
-i num Indent level. Set indentation to this many character spaces per
code nesting level. If set to 0, no indentation is done (all
output is left-justified).
-l List tags. Causes hindent to print a complete list of tags that
it recognizes to stdout, and exits.
-s Strict. Multiple tags per line are broken out onto separate
lines. Can damage the HTML in minor ways by drawing an extra
space character in certain parts of the web page, so save a copy
of your original HTML. This option helps you follow the HTML
code flow visually, especially with computer-generated HTML that
comes out all on one line.
-t num Tab stop. Set the number of spaces that a tab character
occupies on your system. Defaults to 8, but some people prefer
expanding tabs to 4 spaces instead. If set to 0, no tabs are
output (spaces used to indent lines).
-v Version. Prints hindent’s version number to stdout and exits
The -s option is the most useful, it would be the default if it didn’t
damage the HTML code.
Any combination of these options may be used.
Example 1. Download a web page, reformat it, view it:
lynx -source http://www.domtools.com/~pab | hindent | more
Example 2. View only the structure, one tag per line:
lynx -source http://www.domtools.com/~pab | hindent -s -f | more
Example 3. Reformat my home page non-damagingly with 4-space tabs,
keeping a backup copy:
mv index.html index.html.old
hindent -i4 index.html.old > index.html
The master web page for this tool is:
Hindent version 1.1.2
Paul Balyoz <email@example.com>