💻

HTML Entity Encoder

Encode and decode HTML entities

Tip: everything runs in your browser. Encoding makes text safe to display inside HTML (code samples, tutorials); decoding turns entities back into readable characters.

About this tool

This free HTML Entity Encoder converts special characters into their safe HTML entity equivalents — turning characters that HTML treats as syntax into characters that render as plain text. Paste your content and the tool instantly produces the escaped version: angle brackets, ampersands, quotes and special characters all become entity references that any browser displays literally instead of interpreting as markup. Nothing to install, no account needed; encoding happens live as you type. The problem this tool solves is one of the oldest in the web platform: HTML is a language where certain characters mean structure, not content. The moment text contains an opening angle bracket, the browser starts parsing a tag; an unescaped ampersand begins an entity reference; a quote inside an attribute can terminate the attribute early. To display these characters as characters, they must be escaped into entity form — the opening bracket becomes the entity you know as <, the closing bracket becomes >, the ampersand becomes &, and quotes become " and '. This is the same mechanism that lets any web page show angle brackets as visible text instead of broken markup. The security dimension matters just as much as the display one. Encoding user-supplied content before rendering it in HTML is the fundamental defense against cross-site scripting (XSS) — the attack where malicious input smuggles script into a page through unescaped markup. If an application inserts user data into HTML, that data must pass through entity encoding first; doing so renders the content harmlessly instead of executing it. This tool lets you see and produce that encoding by hand — useful for templates, emails, documentation, and for understanding exactly what your framework does for you automatically. Everything runs locally in your browser. Your text is encoded entirely by client-side JavaScript — nothing is uploaded, logged or stored on any server. Disconnect from the internet after the page loads and the encoder keeps working.

Frequently asked questions

What is an HTML entity and what does it look like?+

An HTML entity is a character written in escaped form so the browser displays it as text instead of parsing it as markup. Entities come in two shapes: named references like < > & " © and numeric references like < or < (both representing the opening angle bracket). For example, to show the literal text of a bold tag on a page instead of rendering bold text, the source must contain the escaped form — <b> instead of the raw tag — otherwise the browser renders the formatting and the tags vanish.

Which characters must be encoded in HTML?+

Five are essential for safe content: the opening angle bracket becomes <, the closing bracket becomes >, the ampersand becomes &, and inside attribute values the double quote becomes " and the single quote (apostrophe) becomes '. Everything else — accented letters, currency symbols, emoji — can appear directly in UTF-8 documents, but is often still encoded for compatibility with older systems or for safety in contexts where characters might get corrupted in transit.

How does HTML entity encoding prevent XSS attacks?+

Cross-site scripting happens when user-supplied content is inserted into a page without encoding, so a script tag typed into a comment field becomes real, executable markup. Entity encoding converts that input into harmless visible text — the angle brackets become < and >, the browser displays the attempt as literal characters instead of running it. Encoding all user data before HTML output is the fundamental XSS defense; this tool shows exactly what that encoding looks like and produces it for manual use in templates and emails.

When should I encode HTML entities by hand?+

Whenever your system does not do it for you: hand-built email templates, static pages showing code examples, documentation that displays markup, RSS and Atom feeds, HTML stored in a database and rendered elsewhere, and any framework escape-hatch where you output trusted markup around untrusted text. Modern frameworks like React, Vue, Django and Laravel encode interpolation automatically — manual encoding is for the paths where you step around those protections.

Does my text get uploaded when I encode it here?+

No. All encoding happens locally inside your browser using client-side JavaScript — your input never leaves your device, is never transmitted to any server, and is never logged or stored. After the page loads you can disconnect from the internet and the encoder keeps working. That makes it safe for internal content, credential-bearing templates and anything else you would rather keep on your own machine.

What is the difference between named and numeric entities?+

Named entities like & < © are readable by humans but limited to the official list browsers recognize. Numeric entities like & or & can represent any Unicode character by its code point and need no list. The five essential HTML characters have both forms, and either works identically. Named form is preferred in hand-written content for readability; numeric form is preferred when generating output programmatically for characters without convenient names.

Can I decode HTML entities back to normal text later?+

Yes — entity encoding is fully reversible with no key. The reverse operation (turning < back into the opening bracket, and & back into a bare ampersand) is what a decoder does, and it is the direction to use when cleaning up text that arrived over-escaped: imported content, database values that were double-encoded, or feed data showing & where a simple ampersand should be. Encode before inserting text into HTML; decode when text has been needlessly escaped.

Why do quotes matter so much in HTML encoding?+

Because quotes delimit attributes in HTML: inserting unescaped user data into an attribute lets a single quote character in the data escape the attribute and inject new markup — a classic XSS vector that bypasses encoding of angle brackets alone. That is why complete encoding covers quotes too (" and '), and why this tool encodes them by default. Attribute contexts are where partial escaping fails silently and completely.