HTML Entity Encoder
Encode and decode HTML entities. Safely escape special characters to entities and decode entity-encoded text back to literal characters.
Special characters are converted to safe HTML entities.
About HTML Entity Encoder
Encode special characters like <, >, and & into safe HTML entities, or decode entity-encoded text back to their literal characters. Runs entirely in the browser, so nothing is uploaded.
How to use it
- 1Choose Encode or Decode.
- 2Enter your text or entity-encoded text.
- 3Copy the result.
When to use it
- Safely placing HTML that contains <, >, or & inside another document or a data attribute.
- Cleaning up entity-encoded paste that came from an editor or an email client.
- Preparing snippet content for a CMS that stores raw markup.
Tips & best practices
- Encoding protects display, not security - it is an escaping aid, not a substitute for proper sanitization on the server.
- Decode first if you are unsure whether text is already encoded, to avoid double-encoding.
- Smart quotes and dashes from chat apps can survive a naive copy; re-check the decoded output on sensitive content.
Examples
Encode
Input
<div class="a">A & B</div>Result
<div class="a">A & B</div>Decode
Input
<code>Result
<code>Frequently asked questions
How does encoding work?
It uses a hidden textarea: setting textContent then reading the value encodes; setting innerHTML then reading textContent decodes. This is a browser-native, reliable conversion.
Does it handle quotes?
Yes - double and single quotes are encoded to " and ' as appropriate when encoding.
Does encoding hide my text from the server?
No - it only changes how the browser renders the characters. It is not a privacy or security control.