Entity mistakes produce some of the strangest symptoms in HTML. A page that rendered fine yesterday suddenly shows < as visible text. A copyright symbol turns into a string of code. A tag you wrote carefully prints itself on the page instead of doing its job. The conversion underneath is simple: an encoder turns five characters into their safe entity forms, and a decoder turns entities back into characters. The breakage comes from how that simple conversion gets applied: twice instead of once, to the wrong text, or with a small piece missing.
This guide walks through the mistakes that actually break pages, using the free HTML Entity Encoder/Decoder to check each one. Every fix is a check you can run in seconds: paste the suspicious text, encode or decode it, and compare what comes out with what you meant to store.
Contents
- Quick answer
- What the encoder and decoder actually do
- How to check suspicious text, step by step
- Worked example: the double-encoded code sample
- Limitations worth knowing
- Common mistakes
- FAQs
- Conclusion
Quick answer
The encoder handles five characters: &, <, >, double quote and single quote. Almost every entity failure on a real page comes from six mistakes: a forgotten semicolon, encoding text that was already encoded, encoding markup that was meant to render, choosing an obscure named entity, typing a bare & in front of letters, and treating encoding as a security measure. The HTML Entity Encoder/Decoder exposes all six, because decoding your stored text once shows you exactly what a browser will make of it.
What the encoder and decoder actually do
Encoding converts special characters into their safe entity forms so they can be shown as text inside a page. The tool's own example shows the whole job at once: encoding the text <a href="x">Tom & Jerry's</a> produces <a href="x">Tom & Jerry's</a>. The tag brackets became < and >, the ampersand became &, the double quotes became " and the apostrophe became '. A browser reading that output prints the original line as text and starts no tag.
Decoding runs the other way. It turns <, &, numeric entities and common named entities back into characters: decoding <p> & © gives back <p> & ©.
Two limits are built into that behaviour, and both cause real mistakes. First, obscure named entities are left as they are, so a rare named entity can survive decoding untouched while a common one converts. Second, neither direction knows your intent. The encoder cannot tell markup from text, and the decoder cannot tell singly encoded text from doubly encoded text. Those judgements are yours, which is why the mistakes below are all judgement mistakes rather than tool failures.
How to check suspicious text, step by step
- Copy the text exactly as it is stored or as it appears in your page source, not as it renders.
- Open the HTML Entity Encoder/Decoder and paste the text into the input box.
- Press Decode entities. If the output still contains entities, the text was encoded more than once. If the output is clean characters, one encoding pass was in place.
- Press Encode entities on a clean sample when you need the safe form to store, then copy the result from the output box.
Worked example: the double-encoded code sample
A documentation page wants to show readers the line <a href="x">Tom & Jerry's</a> as an example. Encoded once, correctly, it is stored as <a href="x">Tom & Jerry's</a>, and visitors see the original line as text.
Now the stored text passes through a second system, a template migration or a CMS import, that encodes it again. Every & in the stored form becomes &, so the page now holds &lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&#39;s&lt;/a&gt;. The browser decodes one layer and prints the rest as literal text on the page.
The diagnosis takes one decode in the tool. Paste the stored text and press Decode entities: the output is the singly encoded form, still full of entities, which proves two passes happened. Decode the original sample text instead and you get <a href="x">Tom & Jerry's</a> back, which is what one pass should leave behind. The fix is to store the singly encoded form and stop the second pass, not to decode the page output by hand.
Limitations worth knowing
The encoder covers the five characters that matter for safety and correctness, and nothing beyond them. Symbols such as the copyright sign are a decoding and writing concern, not something the encoder produces from a character you paste.
The decoder's vocabulary has edges. Common named entities, decimal entities and hex entities all convert. Obscure named entities are left as they are, so a decode that leaves one entity standing is not necessarily a bug; its numeric form will convert.
Encoding is not a security filter on its own. It makes the five markup characters display as text, but a real application still has to escape output in the right context, whether that is an attribute, a script or a URL. And since everything runs locally in your browser, the tool checks only the text you paste; it cannot inspect your templates or find where a second pass crept in.
Common mistakes
- Forgetting the semicolon. An entity is the whole sequence, semicolon included:
<,&,©. Leave the semicolon off and the browser may print the raw text, guess at a legacy entity, or absorb the characters that follow. The failure looks random because it depends on what comes next. - Double encoding. Text that is already encoded goes through the encoder again, usually when a CMS, a template and a manual paste each take a turn. The ampersand of
<becomes&, producing&lt;, and visitors read the code instead of the character. One decode in the tool tells you how many layers you have. - Encoding markup that was meant to render. The encoder treats everything you paste as text to be displayed. Paste a whole block of HTML and its tags come back as
<and>, so the page shows its own source. Encode the text content, not the markup around it. - Choosing an obscure named entity. Named entities are easier to read, but the decoder only promises common ones, and older parsers have their own gaps. An obscure named entity can be left exactly as it is while
©or©converts every time. For anything beyond the familiar symbols, the numeric form is the safer habit: in effect there is no difference between©and©. - Typing a bare ampersand before letters. A raw
&followed by letters is how every entity starts, so text like a company name containing&plus a word can be read as the beginning of an entity, especially once a semicolon appears later in the line. The ampersand is one of the five encoded characters precisely because it is never safe to leave it ambiguous. - Assuming encoding makes a page secure. Encoding user input so it displays as text is one narrow job. It does not escape output for attribute, script or URL contexts, and it does not sanitise anything. Treating an encoded field as a safe field is how pages break in the dangerous direction instead of the visible one.
FAQs
Why does my page show entity codes as visible text?
Usually because the text was encoded twice, or stored already encoded and then encoded again on output. The browser receives &lt;, reads it as an instruction to print the characters <, and your visitors see the code instead of a less-than sign. Decode the stored text once to check what you actually have.
Does an entity still work without the semicolon?
Do not rely on it. The semicolon is part of the entity: < is the complete form. Browsers forgive a few legacy cases, but a missing semicolon can just as easily leave the raw text on the page or swallow the characters that follow it.
Which entities can the decoder read back into characters?
Common named entities such as © and , decimal entities such as ©, and hex entities such as ©. Obscure named entities are left as they are, which is why the numeric form is the safer choice for unusual symbols.
Does encoding user input make my page secure? No. Encoding is not a security filter on its own. It makes the five markup characters safe to display as text, but real applications still need output escaped in the right context: attribute, script or URL.
Why did my tag appear as text on the page instead of rendering? Because it was encoded. Encoding turns markup into display text, which is exactly what the tool is for when you want to show code. If a tag was meant to render, it went through the encoder by mistake, often because a whole block was encoded instead of the text inside it.
Conclusion
Most entity breakage is one of six small mistakes, and all six give themselves away under a single decode. When a page shows raw codes, paste the stored text into the HTML Entity Encoder/Decoder and read what comes out before you change anything. The companion guide on encoding special characters for an email template applies the same five characters to templates that have to survive mail clients, and the rest of this series lives in the Developer Tools guides archive.