Skip to content
OddsockLocal
Local
Source text

Formatting

5 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste HTML.
  2. Leave Text whitespace on preserve, or choose collapse outside preformatted elements.
  3. Read the result. Ordinary comments are gone. Attribute values match the input.
  4. Check pre, script and style contents if you switched on collapse.

What is HTML minifier?

HTML minifier deletes comments and compresses the gaps inside tags, and it has an explicit choice about the text between tags. The default is preserve. <div>\n <p title="1 > 2">x <b> y </b></p><!-- hi --></div> becomes <div>\n <p title="1 > 2">x <b> y </b></p></div>. The comment is gone. The two spaces in the title stay. The spaces around y stay. The newline after the opening div stays, because preserve means the text nodes are not collapsed.

Read more

The other setting, collapse outside preformatted elements, is the one that pulls ordinary text whitespace down. pre keeps its contents either way. Attribute values are never edited: the > and the double space inside title="1 > 2" are significant and stay. Conditional comments that start like <!--[if, and server-side <!--# comments, are kept because removing them changes what a legacy page or a server does.

The formatter indents and does not take this whitespace control. Use that page when you want to read the tree. Use this one when the comment and the extra gaps are the problem.

Use cases

  • A snippet should lose an HTML comment before it is inlined, without collapsing the spaces the design depends on.
  • An attribute holds 1 > 2 and a minifier that trims values would change the tooltip.
  • You want the collapse mode for a page of markup, and you need pre blocks to keep their indentation.
  • A conditional comment has to survive because an old template still keys off it.

Comment removed, spaces in text and in the title kept

Text whitespace preserve. <div>\n <p title="1 > 2">x <b> y </b></p><!-- hi --></div>

<div>\n <p title="1 > 2">x <b> y </b></p></div>

Why use Oddsock

Preserve is the default so a first run does not glue words together. Collapse is a separate choice.

Related tools

Using this tool

Text whitespace was preserve. Collapse outside preformatted elements is the setting that reduces those gaps. pre is left alone in both modes.