Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

HTML Formatter

Indent messy markup cleanly, or minify it without breaking pre, textarea or scripts.

Free preview, no sign-upIncluded in your pass Pro tool Pro pass: ₹179 / $5.99 for 30 days On this device: nothing is sent
+3 +1 more details No uploadWorks offline once opened Developer

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.

Pro pass ₹179 for 30 days or ₹79 for 1 week, one‑time. Pro pass $5.99 for 30 days or $2.99 for 1 week, one‑time. How to unlock

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.

See passes (opens in a new tab)

Printing this result is locked in the free preview.

Paste code, drop a file here, or open one from your device.

More options
When minifying

Conditional comments, <!--#include --> directives and framework hydration markers are always kept; <pre>, <textarea>, <script> and <style> are never changed. “Remove spaces between block tags” can change the layout where CSS shows those elements inline or inline-block.

Ctrl/⌘ + Enter formats, add Shift to minify

Your HTML is only shown as code. It is never rendered or run on this page.

Next steps Done. What next?

Start over

A Pro pass unlocks the full result. See passes

All developer tools

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

  1. Paste HTML, drop an .html file onto the box, or use Open file.
  2. Choose indentation, line wrapping, attribute layout and how many blank lines to keep.
  3. Press Format HTML (Ctrl/⌘ + Enter) or Minify HTML.
  4. Copy the result or download it as an .html file — with a pass, or after unlocking this result.

Examples

Indent a one-line menu
Input
<ul class="menu"><li><a href="/">Home</a></li><li><a href="/about/">About us</a></li></ul>
Result
<ul class="menu">
  <li><a href="/">Home</a></li>
  <li><a href="/about/">About us</a></li>
</ul>
Minify while keeping <pre> intact
Input
<div class="card">
  <!-- price block -->
  <p>Total:   <b>₹1,200</b></p>
  <pre>  keep   spacing</pre>
</div>
Result
<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 as inline-block (for example items of a horizontal menu) it can show up as a small gap.
  • If your CSS sets white-space: pre, pre-wrap or pre-line on 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.

How to check that nothing is uploaded

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:

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.