Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

HTML Formatter

HTML

Paste HTML, or

CtrlV paste · Ctrl↵ run now

Formatted HTML
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

Format and beautify HTML from View Source or a build into indented markup, inline CSS and JavaScript too, errors by line

Turn a page’s one-line source into HTML you can read, one element per line, with the styles and scripts inside it formatted as well.

How to use it

  1. Paste HTML on the left, or open an .html file. Pick CSS, JavaScript or GraphQL above it for those.
  2. Choose the indent and the line width long lines wrap at (20 to 320). Under Options, choose how whitespace between inline tags counts, one attribute a line, and the closing > on the last attribute’s line.
  3. Copy or download the result. A tag closed in the wrong place is named with its line and column, marked in your text.

Examples

A navigation list from View Source

Input
<ul class="nav"><li><a href="/">Home</a></li><li><a href="/docs">Docs</a></li></ul><p>Read the <b>docs</b> first.</p>
Result
<ul class="nav">
  <li><a href="/">Home</a></li>
  <li><a href="/docs">Docs</a></li>
</ul>
<p>Read the <b>docs</b> first.</p>

Short elements stay on one line; <b> stays inside the sentence, since a line break there would add a space.

Inline style and script formatted too

Input
<style>.note{color:#555;margin:0}</style><script>if(user){greet(user.name)}</script>
Result
<style>
  .note {
    color: #555;
    margin: 0;
  }
</style>
<script>
  if (user) {
    greet(user.name);
  }
</script>

A tag closed in the wrong place

Input
<div class="card"><span>Total</div>
Result

Line 1, column 30Unexpected closing tag "div"

The <span> is still open where </div> comes.

What formatting changes, and what it keeps

Formatting is done by Prettier, an open-source formatter. It sets the space between tags (line breaks, indents, attributes wrapped past your width), writes tag and attribute names in lower case, quotes attribute values and adds the end tags HTML lets you leave out, like </li> and </p>. Text, attribute values and the contents of <pre> and <textarea> stay as written.

Space can change how inline elements like <a>, <b> and <span> show, so they stay inside their line of text. That is why some short paragraphs keep several tags on one line.

Big pages

Up to 10 MB works, and the page keeps answering while it formats: the work runs in a background thread, a piece at a time. A page that is mostly one long table or list is formatted row by row, with the same indent as in one run.

One element over 500 KB that can’t be split (a huge inline script, say) is left as written, with a note naming its line.

Questions

Does it fix broken HTML?
No. A tag closed in the wrong place stops formatting, with its line and column, so nothing is silently moved. Tags HTML lets you leave open, like <li> and <p>, are fine: their end tags are written in.
Can it format a Vue, Svelte or Angular template?
It reads them as HTML, so attributes like v-if, @click and (click) and text like {{ user.name }} stay as written while the tags around them are laid out.
Is my HTML uploaded?
No. Everything runs in your browser, so your HTML stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. Saved pages can hold tokens in forms or scripts, and the page warns you if it spots a key.

Related tools