HTML Formatter
Format, validate, and minify HTML in your browser, then copy or download the result.
On this page
Format HTML in your browser
HTML Formatter beautifies or minifies HTML source without sending it to a server. Paste markup into the input panel, open a local .html or .htm file, or drop a file onto the editor.
How to use the formatter
- Choose Beautify for readable nested markup or Minify for a compact result.
- Select an indentation style and an optional line wrap length.
- Select Format HTML. The result appears beside the input on larger screens and below it on smaller screens.
- Use Validate to check for unclosed, unexpected, or mismatched tags.
- Copy the result or download it as an HTML file. Clear removes both editors.
Formatting options
Beautify mode supports two, three, four, or eight spaces and tabs. Line wrapping can be disabled or set to 40, 70, 80, 110, 120, or 160 characters. Minify mode collapses ordinary whitespace and removes ordinary comments while preserving conditional and important comments.
Comments and doctypes remain available in beautified output. Void elements such as img, input, and br are not given closing tags. Content inside script, style, pre, textarea, and xmp is kept as raw content so code and preformatted text are not parsed as normal markup.
Examples
Beautify nested elements
<div><h1>Hello</h1><p>World</p></div>
With Beautify and two spaces, the result is:
<div>
<h1>Hello</h1>
<p>World</p>
</div>
Keep inline markup together
<p>Save <strong>now</strong> to continue.</p>
Inline content stays on one readable line:
<p>Save <strong>now</strong> to continue.</p>
Minify a document fragment
<!doctype html>
<!-- remove this comment -->
<div>
<p> Hello </p>
</div>
With Minify selected, the result is:
<!doctype html><div><p>Hello</p></div>
Privacy and limits
Formatting, validation, file reading, copying, and downloading happen in this browser session. The tool does not fetch remote URLs or upload your markup. Local files are limited to 2 MB. Validation checks balanced HTML tags and browser parsing feedback; it is not a complete HTML standards validator.