Skip to main content

HTML Entity Encoder/Decoder

Free HTML entity encoder and decoder: escape special characters or turn entities back into text. Runs in your browser.

Raw text

Stays in your browser

Result

Encoded or decoded text will appear here.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Next steps

Done here? Use the Send to… menu on the result to carry it on to Text Compare, Emoji & Unicode Escape or HTML to Plain Text.

Free HTML Entity Encoder & Decoder

Convert raw text into safe HTML entities, or decode entities like & and → back into their literal characters. The HTML entity encoder turns special characters into entities and back again. It helps web developers safely inspect reserved markup characters in templates, content, and imported text.

When you need HTML entity encoding

Any time raw, user-supplied, or otherwise untrusted text is going to be embedded directly into an HTML document, the characters &, <, >, ", and ' need to be converted to their entity equivalents first — otherwise a browser can interpret them as the start of a tag, an attribute boundary, or a broken attribute value rather than as literal text. This is the same escaping most templating engines and frameworks do automatically, made available here as a standalone tool for cases like preparing a static HTML snippet by hand or double-checking what a library is producing.

How to use this tool

Choose Encode to convert raw text into entity-safe HTML, or Decode to convert entities back into readable text — useful when inspecting HTML source or working with text copied out of a web page. The "encode non-ASCII" option additionally converts accented letters, symbols, and emoji into numeric character references for maximum compatibility with older systems.

Common use cases

  • Safely embedding user-submitted text into a static HTML page or email template
  • Decoding entity-encoded text copied from a webpage's source or an RSS/Atom feed
  • Preparing example HTML/code snippets for documentation where angle brackets need to display literally
  • Converting special characters for compatibility with legacy systems that don't handle raw UTF-8 well

Everything runs locally in your browser — nothing you type or paste here is ever sent to a server.

Worked example

Encoding Tom & Jerry <3 gives Tom &amp; Jerry &lt;3 either way the checkbox is set, since & and < are two of the 5 basic characters. Encoding an arrow character (→) behaves differently depending on the checkbox: left unchecked, it passes through completely untouched; checked, it becomes the numeric &#8594; — never the named &rarr; form, even though Decode understands that name perfectly.

Common mistakes and edge cases

  • Encode and Decode aren't symmetric — in practice, Encode only ever produces the 5 basic entities or numeric references, never a named entity like &rarr; or &copy;, even though Decode fully understands those names.
  • With "encode non-ASCII" off, any character outside the 5 basic ones (accents, symbols, emoji) passes through completely unencoded — that's expected, not a bug, since those characters are already safe as raw UTF-8 in HTML.

Frequently asked questions

What are HTML entities and why do I need to encode them?
HTML entities are text sequences like &amp;, &lt;, and &gt; that represent characters with special meaning in HTML (&, <, >, quotes). If you embed raw text containing these characters directly into HTML markup, the browser can misinterpret them as the start of a tag or attribute — encoding them as entities makes the text display literally and safely.
What's the difference between the two encode modes?
"Basic" only encodes the five characters that are actually unsafe in HTML (&, <, >, ", ') and leaves everything else, including accented letters and emoji, untouched. "All non-ASCII" additionally converts every character beyond the basic ASCII range into a numeric entity, which is useful when you need output that's safe in older documents or systems with limited character-encoding support.
How does decoding work without a security risk?
Decoding uses the browser's own HTML parser through a hidden <textarea> element, which is a well-established safe technique: a <textarea>'s content is treated as plain text by the HTML parser, so nothing inside it is ever executed as a script — only the entity decoding itself takes effect.
Is my text sent anywhere?
No. Both encoding and decoding happen entirely client-side in your browser — nothing you type or paste is sent to a server.
Does Encode produce named entities like &rarr; or &copy;, the same ones Decode understands?
No, and this is worth knowing — as tested, Encode only ever outputs the 5 basic entities (&amp;, &lt;, &gt;, &quot;, &#39;) or, with "encode non-ASCII" on, numeric entities like &#8594; for anything else. It never produces a named entity beyond those 5. Decode is far broader: it uses the browser's own HTML parser, so it understands every named entity the browser recognizes (hundreds of them, including &rarr; and &copy;) — the two directions aren't symmetric.
Why do angle brackets need HTML encoding?
In HTML the characters < and > start and end tags, and & starts an entity. If you want them shown as text, for example to display code on a page or to stop user input being read as markup, write them as &lt;, &gt; and &amp;. Encoding user-supplied text this way is a basic defence against script injection.

Related tools

More Code & Conversion

View all Code & Conversion tools →