HTML Formatter
Beautify or minify HTML code
- Runs in your browser
- Free, no sign-up
- Instant results
Formatted HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello</title>
</head>
<body>
<!-- Main content -->
<main class="page">
<h1>Welcome</h1>
<p>This is <strong>bold</strong>and <em>italic</em> text.</p>
<ul>
<li>One</li>
<li>Two</li>
</ul>
</main>
</body>
</html>How to use the HTML Formatter
- Paste your HTML
- Choose Beautify to indent it or Minify to compress it
- Adjust indentation or comment removal
- Copy the result
Features
- Beautify and minifyReadable, indented markup or compact production HTML from the same input.
- Safe for code blocksContent inside pre, textarea, script and style tags is preserved.
- Size savingsSee how many bytes minification saves.
Frequently asked questions
Will minifying HTML break my page?
It removes comments and collapses whitespace between tags. Whitespace inside text and in pre and textarea elements is preserved, so pages render the same.
Are conditional comments kept?
Yes. Internet Explorer conditional comments (<!--[if …]>) are always kept, even when comment removal is on.
Does it validate my HTML?
No. It formats whatever you paste without rejecting it, so it also works for templates and fragments. Use the W3C validator to check for errors.
How much smaller does minified HTML get?
Typically 10–25%, depending on how much indentation and how many comments the original has. Server compression (gzip or Brotli) reduces it further.
Is my data sent to a server?
No. Everything runs in your browser, so the data you paste never leaves your device. It is safe to use with private or production data.
Related tools
All Developer ToolsCSS MinifierMinify and beautify CSS to reduce file size and improve readabilityJavaScript MinifierMinify and compress JavaScript with TerserMarkdown to HTMLConvert Markdown to HTML with live previewJSON FormatterFormat, validate, and beautify JSON instantlyBase64 Encoder/DecoderEncode and decode Base64 strings instantlyURL Encoder/DecoderEncode and decode URLs for safe transmission