When to use the HTML Entity Encoder
Showing code on a web page
Display HTML examples in tutorials and blog posts without the browser treating them as real tags.
Safe user content
Escape text before placing it into HTML so characters like < and & cannot break the page.
Old systems and emails
Encode accented letters and symbols for systems that do not handle UTF-8 well.
Reading encoded text
Decode text full of &, " and ' from feeds, databases or APIs back into normal characters.
Features and benefits
- Escapes & < > " and ' for safe HTML output
- Optional encoding of all non-ASCII characters
- Named (&copy;), decimal (&#169;) or hex (&#xA9;) style
- Decoder handles named and numeric entities, including emoji
Example
<p>Fish & Chips – £5</p>
<p>Fish & Chips – £5</p>
How the HTML Entity Encoder works
In encode mode, ConvertNest always replaces the five characters that are special in HTML – &, <, >, " and ' – with entities. If you choose to encode non-ASCII characters too, every character outside basic English is written as a named, decimal or hexadecimal entity. In decode mode, the browser’s own HTML parser converts named and numeric entities back into characters safely, without running any code.
A real-life example
A teacher writes a blog post explaining HTML lists and wants to show <ul><li>Apples</li></ul> on the page. When pasted directly, the browser turns it into a real bullet list. Encoding it first gives <ul><li>Apples</li></ul>, which appears on the page exactly as typed, so students can see and copy the code.
Good to know
When you want to show code on a web page – for example in a tutorial – the browser would normally treat < and > as tags. Encoding them as < and > makes them display as characters.
Escaping user input before inserting it into HTML is an important defence against cross-site scripting, but it is only one part of it. Frameworks and templating systems usually do this automatically and should be preferred in applications.
Encoding every non-ASCII character is rarely needed today because UTF-8 is the web standard, but it helps with old systems and some email templates.
Tips for the best results
- Encode only the five special characters for modern UTF-8 pages – it keeps text readable.
- Wrap encoded code examples in <pre><code> to keep spacing.
- Use decimal or hex style when named entities are not supported by the receiving system.
- Decode text twice if you still see entities like &amp; – it was encoded twice.
Common mistakes to avoid
Using entity encoding as the only XSS defence
Context matters: attributes, URLs and scripts need different escaping. Use your framework’s built-in escaping.
Double encoding
&amp; appears on the page. Encode the original text only once.
Encoding everything on a UTF-8 site
It makes the source hard to read without any benefit.
HTML Entity Encoder – frequently asked questions
What are HTML entities?
Codes that start with & and end with ; and represent a character, such as &lt; for < or &copy; for ©.
Which characters must be escaped in HTML?
Always & and <. Inside attribute values, also escape the quote character used. Escaping > is good practice.
Should I encode accented letters?
Not usually. If your page uses UTF-8, accented letters and emoji can be written directly.
Why were some entities left unchanged when decoding?
They are not recognised – often because of a typo or a missing semicolon.
What is ?
A non-breaking space – a space that stops two words from being split across lines.
How do I write the © symbol in HTML?
Type it directly on a UTF-8 page, or use © or ©.