How to Decode HTML Entities: & and é
Last updated: · 3 min read
You will often find codes such as é, & or € in page sources, exported data or database fields. These are HTML entities, and the browser displays them as the characters they stand for. The HTML Entity Decoder converts named entities (&, <, , é) and numeric entities (©, €) back into real characters. Unknown names are left exactly as they are. Decoding runs in your browser, so your text is never sent to a server.
Formula
1. Scan the text from left to right; a sequence that starts with '&' is treated as a possible entity. 2. If it starts with '&#x', read a hexadecimal numeric reference; if it starts with '&#', read a decimal one, and convert it to the Unicode code point. 3. Otherwise look up the named entity (for example amp, eacute or nbsp) in the table; if found, write its character. 4. Leave in place any sequence that is not in the table or does not end with a semicolon. 5. Join the decoded text with the remaining characters and output the result.
This is not a mathematical formula but a parsing algorithm. The list of named entities is based on the table in the WHATWG HTML Living Standard, and numeric references are Unicode code points. Each entity is decoded once per run, so double-encoded text is opened by one level per pass.
What the inputs mean
- Text
- Text that contains HTML entities. It may come from a page source or an API response. If there are no entities, the text comes out unchanged.
Worked example: Decoding mixed entities
- Input: Café & €5 &unknown; text.
- é is a named entity and becomes the character é.
- & and the numeric € (hexadecimal 20AC) become & and € respectively.
- &unknown; is not in the table, so it stays as it is.
Result: Output: Café & €5 &unknown; The unknown entity is left unchanged without causing an error.
How to read the result
If you insert the decoded text directly into another HTML page, any < or > characters in it can be read as tags, which may create a security hole. Do not paste decoded user input into HTML; display it as text instead. Decoding and safe display are separate concerns. This is general information.
Common mistakes
- Expecting entities without a semicolon to be decoded; a sequence such as © is left as it is in this tool.
- Decoding double-encoded text once and expecting the final result; &amp; becomes only &, so a second pass may be needed.
- Assuming invalid numeric references such as � or � are decoded; they stay unchanged.
- Thinking an unknown name such as &unknown; causes an error; the text is simply kept.
- Inserting decoded text into HTML that came from an untrusted source; tags inside it can then run.
Frequently asked questions
What happens to an unknown entity?
Nothing changes; a sequence such as &unknown; remains visible in the text.
Are entities without a semicolon decoded?
No. This tool does not decode entities written without the semicolon, so they stay as they are.
How are numeric entities written?
Decimal form looks like ©, hexadecimal form like €. Both point to a Unicode code point.
Is my text sent to a server?
No. Decoding runs in your browser and the text is not transmitted anywhere.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.