Why a text shows “&” and how to fix it
Published · Updated 3 min read
You have probably seen a text show "Tom & Jerry" instead of "Tom & Jerry" on a site, in an email or in a product page. It is not a fault: an HTML entity has been encoded once too often. This guide explains where the problem comes from and how to fix it.
What an HTML entity is
In the code of a web page, some characters have a special role: the "&" starts an entity, the signs "<" and ">" surround tags. To display these characters as they are, they are replaced by a string of signs called an entity. Five are common.
| Character | Entity |
|---|---|
| & | & |
| < | < |
| > | > |
| " | " |
| ' (straight apostrophe) | ' |
Where double encoding comes from
A text sometimes goes through two systems that each encode: an editor, then a page template. Each pass transforms the "&" of the previous entity. With Encode and decode HTML entities, encoding "Tom & Jerry" gives "Tom & Jerry", then encoding that result gives "Tom &amp; Jerry".
| Step | Text obtained |
|---|---|
| Original text | Tom & Jerry |
| Encoded once | Tom & Jerry |
| Encoded twice | Tom &amp; Jerry |
The browser decodes one level when displaying. A text encoded twice therefore displays with "&" instead of "&".
Decode one level at a time
The tool removes a single level of entities per pass. If the result still contains entities, the "Both" mode flags it and you run the decoding again on the result.
| Text | First decoding | Second decoding |
|---|---|---|
| Tom &amp; Jerry | Tom & Jerry | Tom & Jerry |
| &lt;b&gt;gras&lt;/b&gt; | <b>gras</b> | <b>gras</b> |
Decoding a single level avoids undoing an intended encoding: a code example that must display "&" on screen is written "&amp;" in the page.
Accents and symbols
Decoding understands all the named entities ending with a semicolon, not only the five usual ones. "café à 5 € © 2026" gives "café à 5 € © 2026", the non-breaking space becoming a real non-breaking space. Numeric entities are decoded too: "été" gives "été", and "😀" like "😀" give the same emoji.
What the tool leaves intact
- An unknown entity such as "&inconnue;" is left as it is.
- An entity without a final semicolon, such as "&" or "<" in a sentence, is not touched.
- An address with parameters, such as "https://exemple.fr/?a=1¶m=2©=4", stays exact: "¶m" and "©" are not taken for entities there.
Encode code to display it
To show a piece of code in a page, encode it once. The text "<a href="x">l’été & plus</a>" gives "<a href="x">l'été & plus</a>". Accented letters are not encoded, only the five reserved characters are.
Avoid the problem
Encode only once, at the last moment, when the text is written into the page. To replace in bulk the remains of a bad encoding, Find and replace text is suitable. Web addresses follow another coding, explained in Base64, hash and encoded address, do not mix them up.
Where the problem appears
In a product page, a page title, an automatic email or a field imported from another site: an "&" becomes "&" when the text is encoded twice.
Check the result
- Run the decoding again as long as the tool flags remaining entities.
- Compare with the original text on screen.
- Check the non-breaking spaces and the emoji.
Frequently asked questions
- Why does my text show "&"?
- An HTML entity has been encoded once too often. The browser decodes one level when displaying, the second stays visible.
- How do you fix it?
- Decode one level at a time with the tool, until it no longer flags entities.
- Does the tool decode accents?
- Yes, all the named entities ending with a semicolon, and numeric entities.
- How do you avoid the problem?
- Encode only once, at the last moment, when the text is written into the page.
