HTML Formatter
100% PrivateDeveloper ToolsBeautify messy HTML into clean, indented code, or minify it back down for production.
Runs entirely in your browser. Your input is not uploaded to Ovatly or anywhere else.
- 1Paste your HTML into the input box.
- 2Choose an indent size of 2 or 4 spaces if you plan to format.
- 3Press Format HTML to beautify it, or Minify HTML to compress it.
- 4Copy the result or download it as a text file.
Input: <div><p>Hello</p><p>World</p></div> Formatted output: <div> <p>Hello</p> <p>World</p> </div> Minified, the same markup comes back as a single line with inter-tag whitespace removed.
- The content of pre, textarea, script and style blocks is left untouched when minifying, because whitespace there can be meaningful.
- Formatting fixes indentation only. It does not repair invalid HTML, close missing tags or validate your markup.
- Very large documents are fine to paste, but formatting happens on your device, so extremely big files may take a moment.
Indentation changes do not affect rendering in normal HTML. Minifying removes whitespace between tags, which can very occasionally matter for inline elements separated by a space, so check pages that rely on exact inline spacing.
About this tool
The HTML Formatter tidies messy markup into clean, indented code you can actually read, and can also minify HTML by removing comments and the whitespace between tags. It is the tool you reach for after viewing page source, copying an email template, or inheriting markup that was generated by something else.
Related tools
Part of Ovatly's free tools in Developer Tools.