THE TOOLBOX / HTML & MARKUP UTILITIES
Encode HTML entities
and format markup.
Escape unsafe characters into named, decimal, or hex HTML entities, decode escaped strings, or indent and minify HTML snippets locally.
THE DETAILS
WHATWG HTML character references, OWASP XSS escaping, and void-tag formatting.
1. Step-by-Step Workflow
Select an operation tab (Encode Entities, Decode Entities, Beautify HTML, or Minify HTML), paste your HTML or text into the left editor, and choose Named, Decimal, or Hexadecimal format when encoding. Click Use output as input to chain operations.
2. OWASP Output Encoding & WHATWG Entities
Per the OWASP XSS Prevention Cheat Sheet, untrusted text placed inside HTML body or double/single-quoted attribute contexts must escape &, <, >, ", and '. Non-ASCII symbols and emojis are encoded using their exact Unicode code point via String.prototype.codePointAt().
3. Void-Element Aware HTML Beautifier
Unlike XML, HTML5 void elements such as <img>, <meta>, <link>, <input>, and <br> do not require trailing slashes or closing tags. The beautifier tracks HTML5 void elements so indentation depth stays accurate.
4. Local Privacy & Related Tools
Email templates, CMS snippets, and web components stay 100% inside your browser tab. Need to format strict XML/XPath, optimize inline SVGs, or preview Markdown? Try the XML & XPath workbench, SVG optimizer, and Markdown previewer.
Essential HTML Character Reference Matrix
| Character | Named Entity | Decimal | Hexadecimal |
|---|
& (Ampersand) | & | & | & |
< / > (Angle Brackets) | < / > | < / > | < / > |
" / ' (Quotes) | " / ' | " / ' | " / ' |
© / — (Copy / Em-dash) | © / — | © / — | © / — |
Common HTML Escaping & Minification Pitfalls
Double-Encoding (&amp;)
Running an already-escaped HTML string through an entity encoder a second time turns & into &amp;, causing literal entity codes to appear on screen. Decode first if your source has mixed escaping.
Named Entities in Strict XML / SVG
Strict XML only predefines 5 named entities (&, <, >, ", ') and rejects HTML entities like or ©. Use Decimal or Hexadecimal mode when targeting XML or XHTML.
Whitespace Inside <pre> and <textarea>
Collapsing whitespace when minifying HTML can alter significant line breaks inside <pre> blocks. Review formatted or minified snippets that rely on preformatted whitespace.
Unquoted HTML Attribute Values
Even when HTML entities are escaped, placing user data inside an unquoted attribute (title={val}) allows space characters to inject new attributes. Always wrap HTML attributes in quotes.
Frequently Asked Questions
Why does escaping HTML entities prevent Cross-Site Scripting (XSS)?
Converting the 5 reserved HTML syntax characters (&, <, >, ", and ') into character references (&, <, >, ", ') ensures browsers parse untrusted user input strictly as inert text nodes or attribute values rather than executable <script> tags or event handlers.
What is the difference between named, decimal, and hexadecimal HTML entities?
Named entities (such as © or —) use human-readable names defined in the WHATWG HTML Living Standard. Decimal (©) and hexadecimal (©) numeric character references encode the exact Unicode code point and work in both HTML5 and strict XML parsers.
How does the HTML formatter handle void tags like <img>, <br>, and <input>?
HTML5 defines 14 void elements (area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr) that cannot have child nodes or closing tags. The formatter recognizes void elements so subsequent sibling tags are not over-indented.
When should I enable "Encode all characters"?
By default, only HTML-special characters and non-ASCII Unicode characters (> U+007F) are escaped so your text remains readable. Enable Encode all characters when you need every ASCII character converted into numeric &#...; or &#x...; references.
Are my HTML templates or email snippets processed locally?
Yes. All entity encoding, decoding, indentation, and minification execute 100% in your browser with zero network calls.