Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Web Tools
  3. HTML Entity Encoder/Decoder
Add to favorites

HTML Entity Encoder/Decoder

Encode and decode HTML character references against the full WHATWG table of 2,231 names, with the numeric remapping and the context rules a browser applies.

Runs locally in your browserMore web toolsJump to full guide

Related reading

  • HTML Entities and Special Characters: A Complete Reference for Web Developers10 min read

Initializing in your browser…

You might also like

Meta Tag Generator

Write SEO, Open Graph and X card tags with every value escaped for an attribute, checked against the protocol, and the cut shown per platform.

Password Generator

Generate passwords from the Web Crypto generator by rejection sampling, with the entropy stated exactly from the alphabet, the cost of every rule computed, and crack times against four named attacker models

Favicon Generator

Create favicons from text, emojis, or images with all device sizes (16x16 to 512x512), background/text color customization, border radius control, and batch download

HTML Entity Encoder/Decoder: a worked example

A log line arrives with HTML character references in it and you need to know what it actually said, including whether somebody escaped it once or twice.

The line as it arrived

<p>Hello</p> then <escaped> then € then 😀
What HTML Entity Encoder/Decoder produces

Decoded once, with every reference accounted for

<p>Hello</p> then &lt;escaped&gt; then € then 😀

&lt;      at 0    <    U+003C
&gt;      at 5    >    U+003E
&lt;      at 15   <    U+003C
&gt;      at 21   >    U+003E
&amp;     at 31   &    U+0026
&amp;     at 46   &    U+0026
&#128;    at 62   €    U+20AC
  The standard remaps this one: &#128; is U+20AC (€), not the C1
  control at U+80. These references were written against windows-1252.
&#128512; at 73   😀   U+1F600

Three things in that output are the ones tools get wrong.

`&amp;lt;escaped&amp;gt;` comes back as `&lt;escaped&gt;`, not as a live tag. That input is the correct encoding of the literal text `&lt;escaped&gt;`, so decoding it once has to return exactly that. A decoder that replaces `&amp;` with an ampersand and then keeps replacing produces `<escaped>` instead, which is escaped markup turned back into live markup. In a tool people paste untrusted text into, that is not a formatting slip; it is the escaping being undone for an attacker.

`&#128;` is the euro sign. The HTML Standard remaps 27 numeric references between 128 and 159, because they were written against windows-1252 rather than Unicode, so the character at U+0080 is not what a browser produces here. Returning the literal code point gives an invisible C1 control and disagrees with every browser.

`&#128512;` is one code point above the Basic Multilingual Plane. Decoding it with `String.fromCharCode` yields a lone surrogate rather than the emoji, and encoding the emoji by walking UTF-16 code units yields `&#55357;`, the first half of a surrogate pair, which a browser reads back as a replacement character. A flag emoji, which is two astral code points, comes out as that same broken half twice and loses a character outright.

Every entry is listed with its position and code points because a decoded value is often invisible: the `&nbsp;` this tool reports as U+00A0 is not the U+0020 that looks identical beside it. All 2,231 named references are checked against the browser’s own HTML parser in the project tests, which is the only reference that decides what a character reference means.

About the HTML Entity Encoder/Decoder

Encode text so it cannot be read as markup, or decode character references the way a browser decodes them. The full WHATWG table of 2,231 names, the numeric remapping the standard specifies, emoji handled as code points, and the attribute-context rule that decides whether &lt;code&gt;&amp;lt&lt;/code&gt; without a semicolon is a reference at all.

Key features

  • All 2,231 named references, checked against the browser's own parser
  • Decoding runs exactly once, so escaped markup does not become live markup
  • The 27 numeric references the standard remaps, each named with the reason
  • A null, a surrogate or a value above U+10FFFF resolved to U+FFFD and reported
  • Emoji and other astral characters encoded as code points, not half a surrogate pair
  • The attribute-context rule for the 106 references with no semicolon
  • Three encoding scopes and three reference formats
  • Every reference listed with its position, value and code points
  • A searchable table of the whole standard
  • The text stays in the page and out of the URL; the settings are shareable

How to use

  1. 1Choose Encode or Decode.
  2. 2For encoding, pick how much to encode and whether to write named, decimal or hex references.
  3. 3For decoding, say whether the text came from element content or an attribute value.
  4. 4Paste the text. The result updates as you type, and every reference found is listed with its code points.

How it works

A character reference is how a character that would otherwise be read as markup gets written as text. This tool carries the whole table the HTML Standard defines: 2,231 named references, of which 2,125 end in a semicolon and 106 do not. Every one of them is checked, in the project tests, against the browser's own HTML parser, which is the definition of what a reference means.

Decoding runs exactly once, and that is the part worth understanding. The text &amp;amp;lt; is the correct encoding of the literal characters &amp;lt;, and it must come back as &amp;lt;, not as a live less-than sign. A decoder that replaces &amp;amp; with an ampersand and then keeps replacing turns escaped markup into live markup, which in a tool people paste untrusted text into is how a payload gets assembled rather than defused. When the result still contains references, the page says so and explains why that is correct rather than quietly running again.

Numeric references are resolved the way the standard resolves them, which is not simply "the number you wrote". Twenty-seven values between 128 and 159 are remapped, because those references were written against windows-1252 rather than Unicode: &amp;#128; is the euro sign, not the invisible C1 control at U+0080, and &amp;#153; is a trade mark sign. A null reference, a surrogate, and anything above U+10FFFF all become U+FFFD, since none of them is a character. Each of those is named on screen with the reason, rather than silently producing something invisible.

Encoding walks code points, not UTF-16 code units, which is what makes emoji work. An emoji is one character above the Basic Multilingual Plane, and its reference is &amp;#128512;. A tool that walks code units emits &amp;#55357;, the first half of a surrogate pair, which is not a character and which a browser reads back as U+FFFD; a flag, which is two astral code points, comes out as the same broken half twice and loses a character outright. Three scopes are offered: only the five characters that can change how markup parses, everything above ASCII, or everything the standard has a name for. The five are always encoded, including both quote characters, because an unescaped double quote ends an attribute value and everything after it becomes new attributes.

Decoding is context dependent and the tool lets you say which context you are in. The 106 references with no semicolon are decoded in element content, so &amp;amp becomes an ampersand, but in an attribute value a browser does NOT decode one that is followed by an equals sign or an alphanumeric. That single rule is what keeps a query string like ?a=1&amp;lt=2 intact instead of turning it into ?a=1&lt;=2, and it is the reason the same text can mean two things depending on where it sits.

Every reference found is listed with its position, the characters it produced and their code points, so a value that looks like nothing (a non-breaking space, a combining mark, a replacement character) can still be identified. A search box covers the whole table by name or by pasting a character. The text being converted stays in the page: it is not written into the address bar, the history, or a share link, though the settings are, so a configuration can still be shared without the content going with it.

Tips & best practices

  • If the output still contains references such as &amp;lt;, the input was encoded twice and the result is correct. Decoding runs once on purpose; press Swap and decode again only if you meant to.
  • Choose the attribute context when the text came out of an href or a value attribute. It is the only way &amp;lt=2 in a query string survives.
  • A non-breaking space and an ordinary space look identical and are different characters. The reference list shows the code point of everything it decoded, so U+00A0 and U+0020 can be told apart.

Practical scenarios

  • Pasting a code sample into HTML

    Encode only the five characters that can change how markup parses, so the sample shows as written rather than being parsed as tags.

  • Reading scraped or logged text

    Decode references back to characters, and find out whether what you have was encoded once or twice.

  • Working out what a mystery character is

    Every reference is listed with its code points, so a non-breaking space, a combining mark or a replacement character can be identified rather than guessed at.

  • Fixing a query string that broke

    Switch to the attribute context to see whether an unterminated reference such as &amp;lt=2 was the cause.

Frequently asked questions

Why does decoding leave &amp;lt; in my output?

Because the input was encoded twice, and that result is correct. &amp;amp;lt; is how the literal text &amp;lt; is written safely, so decoding it once must give &amp;lt; back. A decoder that keeps going turns escaped markup into live markup, which is exactly what escaping was meant to prevent.

Why is &#128; the euro sign and not U+0080?

The HTML Standard remaps 27 numeric references in the 128 to 159 range, because they were written against windows-1252 rather than Unicode. Browsers do this, so a tool that returns the literal code point disagrees with every browser. The tool names each remapping when it applies one.

Does it handle emoji?

Yes. Encoding walks code points, so an emoji becomes &#128512; and survives a round trip. Walking UTF-16 code units instead produces &#55357;, half a surrogate pair, which is not a character and which a browser reads back as a replacement character.

What is the difference between the two decode contexts?

106 of the references have no trailing semicolon. In element content a browser decodes them. In an attribute value it does not, when the reference is followed by an equals sign or an alphanumeric, which is what stops a query string like ?a=1&lt=2 from being mangled into ?a=1<=2.

Is this enough to make text safe?

It makes text safe to place in HTML, which is one context. A value going into a JavaScript string literal, a URL, or CSS needs that context's own escaping, and none of them is HTML escaping. Escaping for the wrong context is a common way an injection survives.

Why is a plain space not encoded as &nbsp;?

Because they are different characters. &nbsp; is U+00A0, a non-breaking space; an ordinary space is U+0020 and has no named reference at all. Encoding one as the other changes how the text wraps and what a comparison returns.

Further reading

  • HTML Entities and Special Characters: A Complete Reference for Web Developers10 min read

Private by design

This runs as client-side JavaScript. Keys, tokens, payloads, and other inputs never leave your device.