Skip to content
OddsockLocal
Local
Source text

Formatting

5 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste an HTML fragment or document.
  2. Read the tree at two spaces per level.
  3. Leave entity encoding to the HTML entity page if the text contains & or <.
  4. Use the HTML minifier when you want comments and extra whitespace removed.

What is HTML formatter?

HTML formatter indents a fragment so nested elements stop sharing one line. <div><p>Hi</p><ul><li>One</li><li>Two</li></ul></div> becomes a div, then a p, then a ul, then each li, at two spaces per level. Text nodes stay with their tags when the beautifier keeps them inline.

Read more

It is not the minifier and it is not the entity encoder. Comments stay unless you remove them elsewhere. < and & in text are not rewritten as entities. A page that both indents and escapes will change the document you meant only to read. If the fragment is already pretty and you want bytes removed, the minifier has a separate control for whether text whitespace outside pre is collapsed.

Paste HTML. Script and style contents are text as far as indentation is concerned; this page does not run them and does not pretty-print the CSS inside a style tag with the CSS formatter’s rules.

Use cases

  • A component dump is one long line and you want each li on its own line before editing the copy.
  • You are comparing two fragments and indentation makes the extra wrapper obvious.
  • The minifier collapsed a document and you want a readable copy without reintroducing entity encoding.
  • A template’s div, p and ul should show their nesting at two spaces, matching the CSS formatter’s indent.

A div with a paragraph and a list

<div><p>Hi</p><ul><li>One</li><li>Two</li></ul></div>

<div>\n <p>Hi</p>\n <ul>\n <li>One</li>\n <li>Two</li>\n </ul>\n</div>

Why use Oddsock

Indent only. Entities, comments and minified whitespace are separate jobs, and mixing them makes a diff unreadable.

Related tools

Using this tool

No. Indentation does not escape text. The entity encoder does that, and it will also turn a period into &period;.