# HTML formatter and minifier

Paste HTML to indent it or minify it. Only spaces and line breaks a browser does not show are changed; pre, textarea, script, style and svg stay as written. Nothing is uploaded.

Page: https://toolkitnow.org/tools/html-formatter/

Paste HTML to indent it, or choose Minified. Only spaces and line breaks a browser does not show are changed. The gray text is an example.

## Good to know

### What changes

Line breaks, indentation, and spaces inside tags (`<div  class="a" >` becomes `<div class="a">`). Text, attribute values, comments and the order of everything stay as written. Long lines of text wrap at 100 characters, at a space.

### Why it looks the same

Browsers show a run of spaces and line breaks as one space, and none at all next to blocks such as `div`, `p`, `li` or `br`. Line breaks go only there, so `<b>a</b><i>b</i>` stays on one line: a break between them would add a space you can see. Elements with no box, such as `meta` or `script` in the body, or anything marked `hidden` or `popover`, keep the spaces around them as written, and so do tags the browser ignores or moves (an end tag with nothing to close, text inside a table but outside its cells).

### Kept as written

`pre`, `textarea`, `script`, `style`, `svg` and `math`, inside and out. In `pre` every space shows, and scripts are another language.

### Missing end tags

End tags HTML lets you leave out, such as `</li>`, `</p>` and `</td>`, are not added; the indentation follows where the browser ends those elements.

### Minified

Removes comments, except those some pages need (`<!--[if`, server includes such as `<!--#include`, and Knockout's `<!-- ko`), and every space that does not show. Spaces that show become one. Scripts and styles are not minified.

### Your CSS

The page assumes the browser's usual styles. If your CSS sets `white-space: pre`, or makes an inline element a block (or the reverse), spaces there may show differently: check those parts. Next to a zero-width space (also written `&#8203;`), `<wbr>`, or between Chinese or Japanese characters, a line break and a space can look different, so the kind of whitespace is kept there.

### Open from a link

`?input=%3Cul%3E%3Cli%3Ea%3C/ul%3E` opens the page with that HTML; add `&indent=4`, `tab` or `min`.

Runs in the browser; nothing is uploaded. Part of toolkitnow.org.
