How to format or minify HTML
- Paste your HTML into the Your HTML box, drop an .html file on it, or press Open file. Try an example loads a small, messy page.
- Choose Beautify or Minify. For Beautify, pick the Indent (2 spaces, 4 spaces or tabs) and the Line width.
- Check the result on the right. The size change is shown below it, and in Minify mode also the number of comments removed.
- Copy it or press Download .html.
Features
- Prettier-powered beautifier that also formats inline CSS and JavaScript.
- Indent with 2 spaces, 4 spaces or tabs, and wrap at 80, 100 or 120 characters.
- Conservative minifier written to keep your page rendering the same.
- pre, textarea, script and style kept byte for byte when minifying.
- Conditional comments preserved for old Internet Explorer fallbacks.
- Error location with line and column when the markup is broken.
- Size before and after, with the percentage saved.
Why use Fileora's HTML formatter
Markup copied from a CMS, an email builder or the browser's developer tools is often a single unreadable line. Paste it here and you get a clean, indented document in a moment, without creating an account or uploading anything. The page works on a phone too, which helps when you need to check a snippet away from your desk.
The minifier is intentionally cautious. It never removes a tag or an attribute, so it can't break a template the way aggressive minifiers sometimes do.
How the minifier decides what whitespace to remove
Browsers collapse any run of whitespace in text into a single space, so the minifier does the same. Next to block-level elements, such as a div, a paragraph, a list item or anything in the head, whitespace has no visible effect at all, so it is removed completely. Between inline elements, one space is kept because it can be visible. Content that is whitespace-sensitive, like preformatted text, text areas, scripts and styles, is skipped entirely.
One limit to know: the minifier reads only the HTML, not your CSS. If your stylesheet gives an ordinary element white-space: pre, or turns list items into inline blocks, removed whitespace might show a difference, so check such pages after minifying.
To shrink the rest of the page, use the CSS minifier and the JavaScript minifier. Writing content in Markdown? The Markdown to HTML converter turns it into markup you can format here.