HTML formatter
This HTML formatter takes your source code and returns it neatly indented or minified to the essentials. Everything stays in your browser, nothing is uploaded, and pre blocks, scripts and attribute values are left exactly as they are.
Source: WHATWG HTML Living Standard – Syntax: Void-Elemente, Raw-Text-Elemente (script, style), optionale End-Tags. Updated: .
How it is calculated
How to format HTML
- Paste the source into the box – a whole document or just a fragment.
- Under “Action” choose Format or Minify and set the indentation if needed.
- Copy the result back into your editor.
What formatting does
- Block elements such as
div,ulorsectionget their own lines and their content is indented. - Running text and inline elements (
a,strong,span…) stay together on a line and wrap at about 100 characters so the rendering does not change. - Preformatted content in
preandtextareais kept character for character, because whitespace is visible there. - Scripts and styles are indented as a block; their content is not rewritten.
- Optional end tags such as those of
liortdare added in the output.
What minifying does
Runs of spaces and line breaks become one space, and comments are dropped (conditional comments for old browsers stay). Between block elements the whitespace disappears completely; between inline elements one space remains because the browser shows it. CSS inside style is compacted, JavaScript is left untouched.
Honest limits
This is not a full HTML parser: broken code is not repaired but passed through as closely as possible and reported. Templates with server syntax such as {% if %} or <?php ?> may end up with odd indentation.
Frequently asked questions
How can I format HTML online?
Paste the source, choose “Format” and copy the indented result. No account is needed.
Is my HTML code uploaded?
No. Processing happens entirely in your browser; the code is neither sent nor stored.
How do I format HTML in VS Code or Notepad++?
In VS Code press Shift+Alt+F; in Notepad++ a formatting plugin helps. This tool is the quick option when no editor is at hand.
Does minifying change how the page looks?
Normally not: repeated whitespace collapses to one space in the browser anyway. Pre blocks are the exception and stay untouched.
Can I format CSS and JavaScript too?
Styles and scripts inside HTML are indented but not rewritten. For plain CSS there is the CSS minifier, for JSON the JSON formatter.
Sources and legal basis
- WHATWG HTML Living Standard – Syntax: Void-Elemente, Raw-Text-Elemente (script, style), optionale End-Tags
- MDN – How whitespace is handled by HTML, CSS and in the DOM
- MDN – <pre>: the preformatted text element (whitespace is preserved)
As of: · Editorial policy
Related tools
- JSON formatter, validator and minifierValidate JSON against RFC 8259 with the exact line, column and a plain-English explanation. Beautify or minify, sort keys, copy. Runs locally in your browser.
- SQL formatter (format SQL online)SQL formatter for readable queries: uppercase keywords, indentation, columns and conditions on separate lines. Also minifies SQL. Runs locally in your browser.
- CSS minifier: minify, format and inline CSS into HTMLCSS minifier and formatter, plus a CSS inliner for HTML email: safe transformations, errors with line numbers, all in your browser with no upload. Free.
- Markdown to HTML converter: preview, HTML code, downloadMarkdown to HTML converter with live preview: headings, lists, tables and code following CommonMark. Clean HTML code to copy, safe with no scripts. Free.
- Text Compare: Find Differences Between Two TextsText compare online: see differences side by side or inline, by line, word or character. Jump between changes, save a patch. Private, in your browser.
- Regex TesterTest JavaScript regular expressions live: matches highlighted, capture groups in a table, every part of the pattern explained. Free, nothing uploaded.
- What is my IP address?What is my IP? See your public IPv4 or IPv6 address at once, plus approximate location, internet provider and browser details. Free, never stored.
- HTML to PDF converterConvert HTML to PDF: choose an HTML file or paste code, set the page size and save it as a PDF. Free, no upload, right in your browser.
- JavaScript minifierJavaScript minifier: remove comments and whitespace, shrink the code and see the saving in bytes. In your browser, no upload.