The "tighten" option upon instantiating a new HTML::TreeBuilder is not documented and is on by default. When dealing with templating and debugging them, it is important to get the html out as it was provided to HTML::TreeBuilder, otherwise html data without space or carriage returns makes it virtually impossible to review for humans. How to reproduce: Take some human readable html, i.e. with space and carriage returns, and feed it to HTML::TreeBuilder: my $tree = HTML::TreeBuilder->new(); $tree->parse( $html ); $tree->eof(); print( $tree->as_HTML() ); # All space, indent or cr/lf are now removed, making it unreadable Solution: Add pod documentation for "tighten" option. my $tree = HTML::TreeBuilder->new( tighten => 0, no_space_compacting => 1, ); $tree->parse( $$html ); $tree->eof(); print( $tree->as_HTML() ); # All space, indent or cr/lf are now removed, making it unreadable I don't think HTML::TreeBuilder should make assumptions that transform the way the original document was. If the user wants to tidy up and compress his/her html documents, there are modules dedicated to that. It is up to the user to make those calls.