Skip to content

HTML Formatter

Format and beautify HTML.

Loading…

About HTML Formatter

Markup copied from view-source, an email template or a minified build often sits on a few very long lines. Paste it, pick an indent of two or four spaces and press Format / Beautify: nested elements are indented, lines wrap at 120 characters, and the contents of pre, textarea, script and style elements are left exactly as written so whitespace-sensitive text and inline code are not disturbed. Only whitespace changes. The markup is neither repaired nor validated.

Features

  • Indents nested elements with two or four spaces
  • Wraps long lines at 120 characters
  • Leaves the contents of pre, textarea, script and style untouched
  • Works on whole documents and on fragments
  • Formatting is done by the js-beautify library inside your browser

Limitations

  • Only whitespace changes: unclosed tags, missing quotes and other mistakes are not fixed or reported, and the Valid marker just means the formatter finished.
  • Inline CSS and JavaScript inside style and script elements are left as written, not formatted.
  • The choices are two or four spaces, with no tabs, and the wrap width of 120 characters cannot be changed.

How it works

  1. Paste the HTML, a full page or just a fragment, into the HTML Input panel.
  2. Choose two or four spaces from the Indent menu in the middle column.
  3. Select Format / Beautify.
  4. Read the Formatted HTML panel, then use Copy Output to take it or Clear All to start again.

Example input

<div><p>Hello<span>World</span></p></div>

Frequently asked questions