HTML Entity Encoder Free | Encode & Decode Online

⚙️ Developer Tools Free Forever

HTML Entity Encoder & Decoder

Encode text to HTML entities (named or numeric) and decode HTML entities back to plain text, instantly and entirely in your browser.

Input
Output
Encode Mode
Numeric Format
About This Tool

How this HTML entity encoder picks named entities and lets the browser handle decoding

Encoding text to HTML entities and decoding it back are asymmetric problems. Encoding requires deciding, character by character, whether a named entity exists or a numeric one is needed. Decoding just requires a complete, correct table of every entity HTML defines, which the browser already has built in. This tool takes the practical route on both: it ships a curated table of roughly 90 common named entities for encoding, and it hands decoding entirely to the browser’s own HTML parser instead of maintaining a second, inevitably incomplete table by hand.

Both directions run synchronously in your browser with no network calls. Decoding specifically works by setting the string as the innerHTML of a detached, never-rendered <textarea> element, then reading its .value back out, a technique that gets full HTML5 entity coverage for free instead of maintaining a lookup table by hand.

Four encoding modes, four different scopes

ModeWhat gets encoded
Special characters onlyJust & < > " ', the five characters that are actually dangerous to leave raw inside HTML markup
Named entitiesAny character with a known name in the table (like &copy; or &euml;); anything else above code point 127 falls back to a decimal numeric entity
All non-ASCIISpecial characters get named entities, everything else above code point 127 becomes numeric, ASCII text passes through untouched
Every characterAll characters, including plain ASCII letters, become numeric entities
Step 1 Split into real characters Input is split with Array.from(str) rather than a plain index loop, which correctly keeps surrogate pairs (emoji and other characters outside the Basic Multilingual Plane) as single units instead of splitting them into two broken halves.
Step 2 Look up each character in the named table A direct object lookup checks whether the character has a curated name, covering the five HTML-reserved characters, common symbols like copyright and trademark marks, fractions, accented Latin letters, and a handful of arrows and math symbols.
Step 3 Fall back to numeric Characters without a named entry use codePointAt(0) to get the full Unicode code point (correctly handling astral characters), then format it as either &#x...; hex or &#...; decimal, per the format selector.
Step 4 Decode via the DOM, not a table Setting .innerHTML on a detached element and reading .value back means decoding automatically supports every entity the browser’s HTML parser recognizes, hundreds more than any hand-maintained encode table could practically include.
// simplified from encode() and decode() in the tool source function numericEntity(ch, format) { var code = ch.codePointAt(0); return format === ‘hex’ ? ‘&#x’ + code.toString(16) + ‘;’ : ‘&#’ + code + ‘;’; } function decode(str) { var el = document.createElement(‘textarea’); el.innerHTML = str; return el.value; }
The “named entities” mode is not the same as “special characters” mode for security purposes. If your goal is specifically to prevent HTML injection, use the special-characters-only mode, since that is the minimal, complete set required to make text safe inside HTML markup. The named-entities mode also converts accented letters and symbols to entities, which is a readability and compatibility choice for older systems, not a security boundary, and skipping it does not reopen any injection risk as long as the five reserved characters are still escaped.
Hex vs. decimal numeric format

A separate format selector controls whether fallback numeric entities render as &#8364; or &#x20AC;, both valid per the HTML specification and decoded identically, the choice is purely about which convention your codebase or CMS prefers.

Swap button

Instantly exchanges the input and output boxes, letting you immediately re-run the opposite operation on whatever you just produced, useful for round-trip checking that encode and decode agree with each other.

Array.from for surrogate pairs codePointAt for full Unicode DOM-based decoding

Character reference specifications

  • WHATWG HTML: Named character references is the authoritative, exhaustive list of every named entity a conforming browser must decode, the same list the decode step relies on implicitly.
  • W3C HTML 4 entity sets documents the classic Latin-1, symbol, and special character entity sets that most of this tool’s named table draws from.
  • MDN: HTML entity explains the general syntax rules for named and numeric character references.
  • OWASP: Cross-Site Scripting (XSS) covers why encoding the five reserved characters matters when placing untrusted text into HTML output.

When escaping genuinely matters

Safely embedding user submitted text inside static HTML templates, preparing copyright and trademark symbols for a page footer without worrying about source file encoding, converting curly quotes and em dashes from a word processor export into entities that render correctly regardless of the page’s declared charset, decoding entity laden text copied from an RSS feed or scraped HTML back into plain readable text, and debugging why a string containing an ampersand or angle bracket is breaking an HTML template.

Common Questions

Frequently Asked Questions

An HTML entity is a piece of text starting with an ampersand and ending with a semicolon that represents a character which either has special meaning in HTML markup or can’t easily be typed or displayed directly, such as &lt; for the less-than sign, &amp; for an ampersand, or &eacute; for an accented e. Entities exist so that characters with syntactic meaning in HTML (like < and >, which start and end tags) can appear as literal text on a page without being interpreted as markup.

These five characters have special meaning in HTML syntax: angle brackets define tags, ampersands start entity references, and quotes delimit attribute values. If you insert user-generated or dynamic text directly into HTML without encoding these characters, a browser may misinterpret part of your content as markup, which can break your page’s layout or, more seriously, create a cross-site scripting (XSS) security vulnerability if the text comes from an untrusted source.

Named entities use a memorable, human-readable name like &copy; for the copyright symbol, but only a finite, standardized set of names exist. Numeric character references use the character’s actual Unicode code point, either in decimal (&#169;) or hexadecimal (&#xa9;), and can represent absolutely any Unicode character, including emoji and rare symbols with no assigned name. Numeric references are the safer universal fallback when a character has no standard named entity.

Both represent exactly the same characters and are equally valid HTML, the choice is purely stylistic or based on convention in your codebase or tooling. Decimal is generally more common in hand-written HTML, while hexadecimal is often preferred in contexts that already reference Unicode code points in hex, such as programming documentation, since Unicode code points are conventionally written in hexadecimal (like U+00E9).

The full HTML5 specification defines over 2,000 named character references, far more than commonly appear in typical text, if this tool tried to maintain its own table, it would inevitably miss obscure ones. By handing the text to a real HTML parsing element and reading back its interpreted content, decoding is guaranteed to match exactly what any standards-compliant browser would render, with zero risk of an incomplete table.

This tool decodes entities into plain text within an input field for you to view and copy, it does not execute the result as live HTML or insert it into the page in a way that could run scripts, so viewing decoded output here doesn’t create an XSS risk on this page itself. That said, always re-encode dynamic or user-submitted text before inserting it into your own HTML output, regardless of what tool you used to inspect it.

Yes, this tool processes text using JavaScript’s Unicode code point iteration, so multi-byte characters and emoji spanning multiple UTF-16 code units are correctly treated as single characters when encoding, rather than being split into invalid surrogate halves. This ensures emoji and rare Unicode symbols round-trip correctly through the numeric entity modes.

Privacy Overview

Cookies let this site remember your preferences and show us which tools people actually use. Full detail sits in our Privacy Policy.