Skip to content
ToolMug

HTML Formatter

Make HTML readable again. The formatter indents nested elements, wraps long attribute lists and formats the CSS and JavaScript inside style and script tags as well.

Runs in your browser — nothing you enter is uploaded

How to use

  1. Paste your HTML.
  2. Choose HTML or Vue, indentation and line width.
  3. Click Format, or press Ctrl+Enter (⌘+Enter on Mac).
  4. Copy the formatted markup.

Options explained

Line width
Elements with many attributes are split with one attribute per line when they would exceed this width.
Vue
Formats .vue single-file components — the template, script and style blocks.

Examples

Email template. Paste a one-line HTML email to see its table structure indented.

Copied page source. Format a page’s source to find the section you need.

Frequently asked questions

Why is some text kept on one line?

In HTML, adding whitespace between inline elements can change how the page looks. The formatter respects the CSS display of each element and does not add spaces that would appear on screen.

Does it fix invalid HTML?

It adds closing tags that HTML lets you leave out, such as </li> and </p>. Tags closed in the wrong order cause an error with the line and column, so you can fix them at the source.

Is my code uploaded?

No. Everything runs in your browser.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools