Code Tools · Guide
HTML Formatter / Minifier guide
Beautify HTML with configurable indentation, or minify it safely.
Open the HTML Formatter / MinifierAbout the HTML Formatter / Minifier
Minified or machine-generated HTML is hard to read and review. This tool re-indents HTML with consistent structure using Prettier, or minifies it to reduce page weight.
Your HTML is treated strictly as text — it is never rendered or executed, so pasting untrusted markup with scripts is safe.
How to use
- Paste HTML into the input editor.
- Choose indentation: 2 spaces, 4 spaces or tabs.
- Click Format to beautify or Minify to compress.
- Copy the result. If the markup is malformed, you'll see the parser's error and location.
Examples
Format
Input
<ul><li><a href="/">Home</a></li><li>About</li></ul>Output
<ul>
<li><a href="/">Home</a></li>
<li>About</li>
</ul>Minify
Input
<div>
<!-- nav -->
<p>Hello world</p>
</div>Output
<div><p>Hello world</p></div>What the minifier changes (and what it doesn't)
- Removes HTML comments (conditional comments
<!--[if …]>are kept). - Collapses runs of whitespace in text to a single space, and removes whitespace next to block-level elements where browsers ignore it.
- Leaves
<pre>,<textarea>,<script>and<style>contents exactly as written. - Does not remove optional tags, quotes or attributes — the output stays readable and semantically identical.
Frequently asked questions
Will formatting change how my page looks?
Formatting uses whitespace-sensitive rules based on each element's default CSS display, so inline content isn't broken apart. Pages that change display or white-space with custom CSS can still be affected in rare cases.
Are embedded CSS and JavaScript formatted?
Yes. Contents of <style> and <script> tags are formatted with Prettier's CSS and JavaScript formatters.
Is my HTML executed or uploaded?
Neither. Processing happens in your browser on plain text; nothing is inserted into the page and nothing is sent to a server.
Ready to try it? Everything runs locally in your browser.
Open the tool