HTML Formatter
Indent messy markup cleanly, or minify it without breaking pre, textarea or scripts.
Try before you buy.
- Free preview: the first lines of the formatted or minified HTML (up to 20), with every warning and size.
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment unless you choose automatic renewal. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment unless you choose automatic renewal.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
Your HTML is only shown as code. It is never rendered or run on this page.
The input has changed since this result was made — format again to update it.
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the HTML Formatter
Paste HTML — a minified page, template output or markup copied from DevTools — and get properly nested, indented code. The CSS inside <style> and the JavaScript inside <script> are formatted too, while <pre> and <textarea> content is left exactly as it is, because whitespace there is visible.
Minify makes HTML smaller without changing how it looks: runs of spaces and line breaks in text become a single space, whitespace inside tags is tidied, and comments are removed — except conditional comments, server-side include directives and the markers frameworks such as React and Vue need for hydration. Your markup is only ever handled as text: it is never rendered or run.
Without a pass you see a free preview: every warning and size, with the first lines of the formatted or minified HTML. A Pro pass unlocks the whole result, with Copy and Download.
How to use it
- Paste HTML, drop an
.htmlfile onto the box, or use Open file. - Choose indentation, line wrapping, attribute layout and how many blank lines to keep.
- Press Format HTML (Ctrl/⌘ + Enter) or Minify HTML.
- Copy the result or download it as an
.htmlfile — with a pass, or after unlocking this result.
Examples
<ul class="menu"><li><a href="/">Home</a></li><li><a href="/about/">About us</a></li></ul>
<ul class="menu"> <li><a href="/">Home</a></li> <li><a href="/about/">About us</a></li> </ul>
<div class="card"> <!-- price block --> <p>Total: <b>₹1,200</b></p> <pre> keep spacing</pre> </div>
<div class="card"> <p>Total: <b>₹1,200</b></p> <pre> keep spacing</pre> </div>
One space is left between elements by default; turn on Remove spaces between block tags to drop those too.
Common uses
- Reading the minified HTML of a page or an email template.
- Tidying markup generated by a CMS, a page builder or a templating engine before editing it by hand.
- Minifying static pages, embeddable widgets or HTML email without a build step.
- Finding unclosed comments, tags and
<script>elements — they are reported with their line number.
What the minifier changes
- Runs of spaces, tabs and line breaks in text become one space. Browsers display them the same way, so the page looks unchanged. Next to Chinese, Japanese or Korean text a line break stays a line break (still one character), because browsers may hide it there instead of showing a space.
- One space is kept between elements by default, because inline and inline-block elements (links, buttons, menu items) would otherwise touch. Remove spaces between block tags also drops whitespace next to block elements such as
<div>,<p>and<li>, like most minifiers do. - Whitespace in
<head>and around<html>,<head>and<body>is removed, because browsers never display it. - Inside tags, extra spaces between attributes are removed; attribute values are kept exactly as written, quotes included.
<pre>,<textarea>,<script>,<style>, the doctype, CDATA sections,<?php … ?>and<% … %>blocks are copied unchanged.- As a final check the result is parsed again and must have the same tags, attributes, comments and text as the original, ignoring only whitespace.
Formatting options explained
- Wrap long lines at breaks long lines between words and between attributes. It never splits an attribute value.
- Attributes → One per line puts each attribute of a tag that has two or more on its own line — handy for long class lists and framework templates.
- Format CSS & JS formats
<style>and<script>with the same engines as the CSS Formatter and the JavaScript Formatter. Turn it off to leave them exactly as they are. - Template tags such as
{{ }},{% %},<% %>and<?php ?>are kept intact, although the layout around them may not be perfect.
Limitations
- Formatting uses the open-source js-beautify HTML beautifier. It does not validate HTML or repair unclosed tags; problems such as an unclosed comment or
<script>are reported as warnings. - Formatting puts block elements such as
<div>and<li>on their own lines, and never adds whitespace between inline elements such as<a>and<b>. Browsers ignore that new whitespace in normal layout, but between elements your CSS displays asinline-block(for example items of a horizontal menu) it can show up as a small gap. - If your CSS sets
white-space: pre,pre-wraporpre-lineon other elements, whitespace there matters, and both formatting and minifying change it. Keep such text in<pre>or<textarea>(never changed), or use Keep line breaks when minifying if only line breaks matter. - Framework hydration markers are kept, but test a server-rendered page after minifying it — or turn off Remove comments.
Privacy
On this device: nothing is sent
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What do I get without a pass?
Without a pass, HTML Formatter shows the first lines of the formatted or minified HTML (up to 20), with every warning and size. Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment unless you choose automatic renewal, unlocks the full result. The pricing page lists the passes and their prices.
Is my HTML uploaded, rendered or run?
No. It is processed as plain text in your browser and is never sent to a server. It is not displayed as a web page, and any scripts in it are not executed.
Why is there still a space between some tags after minifying?
Removing every space between elements can make inline items such as links and buttons touch. The default keeps one space; turn on Remove spaces between block tags to remove whitespace around block elements as well.
Does it fix invalid HTML?
No. It re-indents what you give it and keeps your tags as they are. Unclosed comments, tags and script blocks are pointed out so you can fix them.
Are conditional comments kept?
Yes. <!--[if IE]> … <![endif]--> blocks and the <!--[if !IE]><!--> … <!--<![endif]--> pattern are always kept, as are <!--#include … --> server-side includes.
Do I need a pass?
To copy or download the whole formatted or minified HTML, yes: a Pro pass unlocks every Pro tool. Without a pass you see a free preview of your own result: the first lines of the formatted or minified HTML (up to 20), with every warning and size. Your HTML is never locked and never uploaded.
Learn more
Lessons on MySmartCoPilot Learn that use this tool:
- HTML, the DOM and DevTools for scrapers Free lesson, Pro answers
- Headings, paragraphs and the document outline Free lesson, Pro answers
- Page structure: header, nav, main and footer Free lesson, Pro answers