HTML Entity Encoder
Escape text for HTML text content by assigning it to a DOM element's textContent and reading innerHTML.
How to use
- Enter literal text and run the HTML entity encoding.
Capabilities and scope
The browser serializer decides which characters such as <, >, and & need entity-style escaping in that context.
How it works
A temporary div receives textContent=input and its innerHTML becomes the output.
Example
Literal <b>&</b> is represented as text rather than active markup.
Useful for
- Represent user text literally inside HTML source
Before you use it
- This is not a dedicated attribute-value escaper and does not let you choose a particular named-entity style.
Frequently asked questions
Is every character converted to &name;?
No. Only characters requiring escaping in HTML text context are serialized specially.