Skip to content
Developer

HTML Formatter

Paste HTML to beautify it with consistent indentation, or switch to minify mode to strip whitespace and comments. Choose 2 spaces, 4 spaces or tabs.

Your HTML is processed in your browser and is not uploaded to a server.

How to use this html formatter

  1. Choose Format (beautify) or Minify.
  2. For Format, pick the indent size: 2 spaces, 4 spaces or tab.
  3. Paste your HTML — output appears below with a size comparison.
  4. Copy the output, or download it as an .html file.

Frequently asked questions

Does it preserve <pre>, <script> and <style> content?

Yes. Content inside pre, script, style and textarea is treated as raw text and is not re-indented or collapsed, so code blocks stay intact.

What does Minify remove?

All HTML comments and unnecessary whitespace between tags. A single space is preserved between text and inline tags so spacing in rendered output is unchanged.

Does it fix invalid HTML?

No. The formatter respects the structure you give it. If your HTML is invalid (unclosed tags etc.) the output may also be invalid — fix the markup first.

Is my HTML uploaded?

No. Formatting and minifying happen entirely in your browser.