HTML Formatter
Paste HTML source to pretty print it with two spaces, four spaces or tabs, or open the HTML minifier for compact output. Copy or download the result. Original tags, attributes, entity references and comments remain; pre, textarea, script, style and title contents stay as written. Notes identify nesting problems without inserting missing tags. Ordinary whitespace is rewritten, so check CSS rules that make spaces or line breaks significant.
- Mode
- Indent
- Lines
- 7
- Saved
- none
7 lines out, 69 characters, nothing to report.
No nesting problems were reported for this markup. to see what the notes look like.
- <div> <p>Hi</p> <ul> <li>a</li> <li>b</li> </ul> </div>
- <div><p>Hi</p><ul><li>a</li><li>b</li></ul></div>
- <div> <pre> two spaces kept</pre> </div>
Up to 2,000,000 characters in one pass, read here in your browser with nothing uploaded and no account. Indentation output is limited to 8,000,000 characters; larger results are refused with the input left intact. Minify takes out the whitespace and nothing else: comments, attributes and entity references all survive it. The mode, the indent and the draft are kept in this browser alone, drafts up to 200,000 characters, and the Start over button above the tool forgets them.
Common questions
- Will formatting or minifying change how my page renders?
- It is designed around ordinary HTML block and inline layout: existing inline spacing stays significant, and protected pre, textarea, script, style and title content is copied intact. Template and datalist content and ordinary hidden-attribute subtrees stay as written, with their outer inline spacing preserved. A dialog without an open attribute is hidden; any open attribute, including open="false", opens it. Unregistered HTML elements use default inline layout; hidden=until-found keeps its block or inline layout. The tool does not evaluate CSS. A div with white-space:pre or an element whose display is changed by a stylesheet can depend on whitespace the formatter changes. Review the output in your actual page before applying it; it is not a lossless HTML/CSS transform.
- What happens to the content of pre, textarea and script?
- Those elements, along with style and title, are copied from your source to the output byte for byte, tags, indentation, tabs and blank lines included. Quoted declaration identifiers, quoted tag attributes and raw bodies do not end a pre block early. Script boundaries follow HTML script-data escaping states, with CDATA-aware scanning in SVG and MathML and HTML boundaries at their HTML integration points. The opening tag may move to its parent indentation; the bytes inside remain as written. Unterminated protected content and unfinished tags are retained and reported. Legacy HTML listing content is also preserved. An HTML plaintext opening keeps every remaining character through the end of the source, including apparent closing tags; plaintext does not need an end tag. HTML boundary scanning assumes scripting is enabled, without executing scripts: noscript bodies stay literal through their matching end tag, including apparent tags inside them. SVG and MathML noscript elements use markup boundaries, except at HTML integration points.
- What are the notes listed under the output?
- They are the places where your markup leaves work to the parser, reported instead of applied. HTML lets you leave out the end tag of a list item, a paragraph, a table cell and several others, so a second list item closes the first one; that is noted with both line numbers. An end tag that crosses another, an end tag with no opening tag above it, a tag still open at the end of the document, an unterminated comment or tag, and a trailing slash on an ordinary HTML element (which does not close it, whatever XML habits suggest) are all reported the same way. Nothing in the output changes because of a note: no closing tag is inserted, nothing is moved, and the indenting simply follows the nesting a browser would read.
- What does Minify remove?
- It removes eligible formatting whitespace and collapses ordinary text whitespace. It keeps comments, original tags, attributes, quoting, entities and protected pre, textarea, script, style and title contents. It does not minify CSS or JavaScript, remove comments, shorten attribute names or produce gzip/Brotli compression. Meaningful CSS-dependent whitespace may need to stay as originally written.
- Is my HTML uploaded anywhere?
- No. The formatting happens in your own browser, which matters when the markup is a page from a client site or an email template. There is no account, no sign-up and no upload, and the tool makes no network request of its own. Your draft is remembered on this device alone so it is still there when you come back: up to 200,000 characters of it is written to local storage, a longer paste still formats in full but is not stored, and the Start over button above the tool forgets both the draft and your mode and indent settings.
- How much HTML can I paste at once?
- Up to 2,000,000 input characters in a single pass. Formatting also checks an 8,000,000-character output budget before adding indentation, because deep nesting can make output much larger than input. If either budget is exceeded, the tool refuses the result and keeps your input intact. Choose Minify, use tabs, reduce nesting or format smaller sections. It never truncates the document.
- Can I indent with tabs?
- Yes. The indent control offers two spaces, four spaces and a tab, and the choice is remembered in this browser for next time. A tab is written as a real tab character, one per level, so the file indents to whatever tab width your editor is set to.
- Why did some elements stay on one line?
- Because breaking them would be noise. An element whose whole content is text and inline tags, such as a paragraph or a list item, is printed on one line when that line fits in 120 characters including its indentation. Past that the content moves onto its own line between the opening and closing tags, which is safe because the whitespace at a block edge is not rendered. The text inside is still never wrapped, so a long paragraph stays on one long line rather than being rewrapped into a shape you did not choose.
- Can I pretty print an HTML table or email template?
- Yes, as HTML source. Paste the table or the template and choose Format; no cell values, attributes or tags are deliberately rewritten. This is source layout, not a visual table designer or an email-client compatibility test. Embedded CSS and script bodies remain unchanged. Use HTML Viewer to inspect the markup with its stated preview restrictions.
- Does this validate or repair HTML, JSX, PHP or template syntax?
- The notes cover the formatter’s tag scanner and nesting assumptions. It does not enforce the complete HTML standard, fix missing tags, or parse JSX, PHP, Angular, Django or other template languages. Use HTML Validator for the documented authoring rule set; passing that tool is still not a W3C conformance certificate.
- Can I unminify HTML?
- Format can re-indent compact HTML source. It cannot recover removed comments, original whitespace, source code maps or shortened names. There is no URL fetch or file picker; paste source from your editor, then copy or download the result.
- Can I use this HTML formatter as browser software on Linux?
- Yes. This is a standalone browser tool, including in a browser on Linux. Paste HTML source, choose Format or Minify, then Copy or Download the output. It does not install an editor extension or run a server build step.
Keeps original tags and the contents of pre, textarea, script, style and title; formatting rewrites whitespace elsewhere. CSS can make that whitespace significant.