HTML Formatter
Beautify or minify HTML code instantly in your browser — no data leaves your device.
mondaytool.com/tools/html-formatter ·
Made with MondayTool · mondaytool.com/tools/html-formatter
Last updated:
Beautify or minify HTML
This free HTML formatter has two modes. Beautify puts each tag on its own line with clear indentation, which makes minified or messy HTML readable. Minify does the opposite and removes comments and extra whitespace to make the file smaller. Processing runs in your browser.
How to use it
- Paste your HTML into the HTML Input box. A sample page is loaded to start with.
- Choose Beautify or Minify.
- In Beautify mode, pick an indent of 2 or 4 spaces.
- Click Beautify HTML or Minify HTML.
- Check the line counts and click Copy to copy the output.
How it works
Beautify reads the HTML from left to right:
- Each opening tag goes on a new line and increases the indent by one level.
- Each closing tag reduces the indent by one level.
- Void elements such as
img,br,meta,linkandinput, and tags ending in/>, do not change the indent. - Comments and the DOCTYPE are kept on their own lines.
- The content of
scriptandstyletags is kept, with each line trimmed and indented one level deeper.
Example: <ul><li>Home</li></ul> with a 2-space indent becomes:
<ul>
<li>
Home
</li>
</ul>
Minify removes HTML comments, removes whitespace between tags, collapses runs of spaces, and joins all lines into one.
Limitations
- Inline tags such as
strongandaare also put on separate lines, which can add visible spaces between words. - Tags left open, such as a
<p>or<li>without a closing tag, push the indent too far to the right. - Whitespace inside
preandtextareais not preserved. - The formatter does not validate HTML or report errors in your markup.
Frequently asked questions
Is this HTML formatter free?
Yes. There is no sign-up and no limit on how often you use it.
Is my HTML sent anywhere?
No. Formatting and minifying happen in your browser and the output is not saved.
Related Developer Tools
Browse all tools from the same category.
Domain Authority Checker
Check Moz authority, page authority, spam score, and backlink metrics
Open toolSEO Audit Tool
Audit a website URL for technical SEO, metadata, headings, broken internal links, hreflang, canonical and X-Robots-Tag checks, with report exports
Open toolShowing 1-2 of 49