HTML Formatter
To format HTML online, paste a document or fragment and choose Pretty with 2-space, 4-space, or Tab indent — or Minify for a compact line. Pretty reindents it with Prettier at an 80-character line width; Minify strips comments and collapses whitespace between tags. Then press Copy. HTML that cannot be parsed shows an error beside the input, scripts never run, and nothing is uploaded.
Updated
Paste an HTML document or fragment and format it locally — pretty-print with 2-space, 4-space, or Tab indentation for reading and review, or minify to a compact line. Closing the tab drops the workspace; we do not write it to localStorage or send it to a formatter API. This page is an HTML beautifier / pretty-printer for markup you already have, not a Markdown converter and not a live browser inspector.
Formatting runs in the browser with a client-side HTML formatter: Prettier, the open-source code formatter, with its HTML plugin, loaded into your browser so your HTML is never uploaded. If the text cannot be parsed as HTML, the page shows an error next to the input instead of guessing at a fix. Tags and text are preserved as written; this page reflows whitespace and indentation, it does not rewrite your content, fetch remote assets, or execute scripts.
Applies in Pretty mode. Minify ignores indent and collapses whitespace.
Paste an HTML document or fragment. Whitespace and indentation only — scripts are not executed and remote assets are not fetched. Nothing is uploaded.
Output
Whitespace formatter only — does not convert Markdown, encode entities as the primary job, execute scripts, or fetch remote assets. Closing the tab drops the workspace. Shipping the markup? Use the layout-safe HTML Minifier for comment controls and bytes saved.
How does the HTML Formatter work?
1. Paste HTML
Drop in a document or fragment. Load example fills a tiny fictional demo page.
2. Format locally
The browser runs a client-side HTML beautifier (Prettier HTML path or equivalent) in this tab. Nothing is uploaded and no remote resources are fetched.
3. Pretty-print or minify
Choose Pretty with 2-space, 4-space, or Tab indent for reading and review, or Minify for a compact paste. Tags and text stay as written; only whitespace and indentation change.
4. Copy the result
Copy the formatted HTML. Closing the tab drops the workspace. Need Markdown conversion, entity encode, or CSS instead? Use HTML to Markdown, HTML Encode, or CSS Formatter on this site.
Questions about HTML Formatter
- What does this HTML formatter do?
- It pretty-prints (beautifies) or minifies HTML in your browser. Paste a document or fragment, and it reformats whitespace and indentation so markup is easy to read — or collapses it for a compact paste. It is a local HTML beautifier, not a Markdown converter and not a live DevTools inspector.
- Does it upload my HTML?
- No. Formatting runs entirely in this tab. There is no account, no server-side formatter, and no file upload. The text you paste stays here until you clear it or close the page. We do not write it to localStorage. That is the same privacy rule as CSS Formatter, XML Formatter, SQL Formatter, and JSON Formatter on this hub.
- Why is there no /html-beautifier/ URL?
- One canonical address with a trailing slash: /developer/html-formatter/. Queries like "html beautifier", "format html", and "online html formatter" can land here. We do not publish stub alias slugs that would split the address people and search engines should share, and we do not leave empty beautifier URLs that 404.
- What happens if my HTML is invalid?
- You get a short error next to the input and the output stays empty. The page does not invent missing closing tags or silently rewrite broken markup. Fix the HTML in an editor (or trim the fragment) and paste again — formatting only runs when the client-side beautifier can parse the text.
- How is this different from HTML to Markdown, Markdown to HTML, or HTML Encode?
- HTML to Markdown and Markdown to HTML convert between formats. HTML Encode escapes or unescapes entities (<, &, and friends). This HTML formatter only pretty-prints or minifies whitespace and indentation — it does not convert formats or rewrite entities. For a minify-first page with layout-safe whitespace rules, comment controls, and byte savings, use HTML Minifier at /developer/html-minifier/. They share the local-only privacy rule but solve different jobs.
- Does it run scripts or fetch remote assets?
- No. The formatter never executes script tags, never loads images or stylesheets referenced in your markup, and never follows links or iframes. It only reflows whitespace and indentation for the text you pasted in this tab — nothing is fetched from remote URLs.
- Can I change the indent width?
- Yes. In Pretty mode, choose 2 spaces, 4 spaces, or Tab. The default is 2 spaces, matching Prettier's usual HTML tabWidth. Minify ignores indent and collapses the markup to a compact line.
- Can it handle very large HTML documents?
- The page is meant for typical templates and page-sized markup. Multi-megabyte dumps can strain browser memory and slow the tab. There is no upload size limit, because nothing is uploaded — the limit is your browser's memory and responsiveness. For huge production dumps, prefer a local CLI formatter.
- Is this a Markdown converter, CSS formatter, or XSS sanitizer?
- No. It formats HTML whitespace only. It does not convert HTML to Markdown (use HTML to Markdown), does not beautify CSS (use CSS Formatter), and does not sanitize markup for safe CMS paste. Entity encode/decode lives on HTML Encode.
What else can I open?
- JWT Token DecryptDecrypt a compact JWE locally with Web Crypto.
- CSS FormatterPretty-print or minify CSS locally in the browser.
- SQL FormatterPretty-print SQL queries locally — does not execute SQL.
- Flexbox GeneratorBuild a CSS flexbox layout visually with a live preview, then copy the CSS or Tailwind classes.
- YAML FormatterPretty-print and validate YAML in the browser — keeps YAML as YAML, nothing uploaded.
- HTML MinifierShrink HTML locally with layout-safe whitespace rules and see bytes saved.
These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.