HTML Formatter & Minifier
Paste HTML and either format it with readable 2- or 4-space indentation or conservatively minify it. Everything runs locally in a browser worker — your HTML is never uploaded, rendered, or executed. Formatting and minifying transform the source text only: comments, embedded scripts and styles, and whitespace-sensitive content like <pre> and <textarea> are preserved, and embedded JavaScript and CSS are left untouched. This tool does not validate, repair, or sanitize markup.
Format HTML for easier reading
Paste HTML and choose 2- or 4-space indentation. Processing happens locally in your browser and returns readable source without rendering it. Inline whitespace is preserved, so “<span>A</span><span>B</span>” and “<span>A</span> <span>B</span>” stay meaningfully different.
Minify HTML conservatively
Minify removes unnecessary source-layout whitespace while preserving comments, embedded scripts/styles, and documented whitespace-sensitive content like <pre> and <textarea>. It is intentionally conservative — it does not remove comments, strip attribute quotes, drop optional tags, or minify JavaScript or CSS — so it does not aim for the smallest possible HTML.
Formatting is not validation or sanitization
This tool does not prove markup is valid and does not make untrusted HTML safe to render. It transforms source text: dangerous-looking constructs such as <script> tags or onerror handlers are preserved as inert text, not removed. Do not treat the output as sanitized.
Does PocketSpry execute my HTML?
No. HTML is processed as source text in a browser worker and never rendered by this tool. It is not uploaded to a server, and it is never inserted into the page or previewed.
Frequently asked questions
- What does the HTML Formatter do?
- It rewrites HTML source with consistent, readable indentation (2 or 4 spaces), preserving inline whitespace and embedded content.
- What does the HTML Minifier do?
- It conservatively removes unnecessary source-layout whitespace while keeping comments, embedded scripts/styles, and whitespace-sensitive content intact.
- Does it execute my HTML?
- No. HTML is processed as source text in a browser worker and never executed.
- Does it render a preview?
- No. There is no preview; the result is plain source text you can copy.
- Does it sanitize HTML?
- No. It is not a sanitizer. Dangerous-looking source is preserved as inert text, so the output is not safe to render just because it was processed.
- Does it validate HTML?
- No. Successful processing does not mean the markup is valid.
- Does it fix broken HTML?
- No. It does not repair markup, invent closing tags, or rewrite structure.
- Does it preserve comments?
- Yes, in both Format and Minify.
- Does it minify JavaScript inside script tags?
- No. Embedded JavaScript is left as-is in both modes.
- Does it minify CSS inside style tags?
- No. Embedded CSS is left as-is in both modes.
- Does it preserve <pre> and <textarea> whitespace?
- Yes. Whitespace-sensitive content is preserved.
- Can it process HTML fragments?
- Yes. Fragments stay fragments — no <html>, <head>, or <body> wrappers are added.
- Can it process full HTML documents?
- Yes. An existing <!DOCTYPE html> and document structure are preserved.
- Does it support JSX, Vue, or Svelte templates?
- No. It processes HTML source only, not framework templates or XML.
- Can I choose the indentation?
- Yes, 2 or 4 spaces when formatting.
- Does Minify remove attribute quotes?
- No. Attribute quotes are preserved.
- Does PocketSpry upload my HTML?
- No. Processing happens entirely in a browser worker; nothing is sent to a server.
- Is the output safe to render if the input was untrusted?
- No. This tool does not sanitize HTML. Untrusted output is not safe to render.