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
- Choose Format (beautify) or Minify.
- For Format, pick the indent size: 2 spaces, 4 spaces or tab.
- Paste your HTML — output appears below with a size comparison.
- 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.
Why does my formatted HTML look different from what Prettier produces?
Every formatter has opinions: where to break long attribute lists, whether to put closing brackets on their own line, how to handle inline elements inside block elements. This tool aims for compact readability; Prettier favours wider wrapping at 80 columns by default. Pick one tool per project and configure it once — mixing formatters guarantees noisy git diffs.