HTML Entity Encoder
Encode special characters for text inside an HTML element.
Try a small example
Try a small example
Load the fictional example in a cleared form. Check the options, run the tool if needed, and compare the result below.
Encode ampersands, angle brackets, double quotes and apostrophes for HTML text content. Paste text and run the encoder. It replaces ampersands, angle brackets, double quotes and apostrophes with character references for text inside HTML elements. Already encoded entities are encoded again, so & becomes &. Use the output only in HTML text content, not as a general-purpose sanitizer. This encodes existing entities too: & becomes &. It is not a universal sanitizer or output encoding for attributes, scripts, styles, or URLs.
Text for HTML text content
<p title="Demo">Tea & coffee</p>
Expected output
<p title="Demo">Tea & coffee</p>
The example is unavailable until the tool is ready.
Text is processed in your browser.
Share this tool
Only the tool’s public link is shared. Your inputs and results stay here.
Show link to copy manually
Quick answer
Encode ampersands, angle brackets, double quotes and apostrophes for HTML text content.
The page and its assets load from the site; this operation uses your entered values only in this browser and does not send them to a calculation endpoint.
How to use it
Paste text and run the encoder. It replaces ampersands, angle brackets, double quotes and apostrophes with character references for text inside HTML elements. Already encoded entities are encoded again, so & becomes &amp;. Use the output only in HTML text content, not as a general-purpose sanitizer.
Limits
This encodes existing entities too: & becomes &amp;. It is not a universal sanitizer or output encoding for attributes, scripts, styles, or URLs.
Frequently asked questions
Which characters does it encode?
It converts ampersands, less-than and greater-than signs, double quotes, and apostrophes to character references. For example, A & B becomes A & B.
What if my input already contains an entity such as &?
The ampersand is encoded too, so & becomes &amp;. This is expected when encoding literal text for an HTML text node.
Can I use the result anywhere in HTML?
No. This is for text content inside an HTML element. It is not a general sanitizer or safe output encoding for scripts, styles, URLs, or other contexts.
Sources and references
These references document the cited standard or browser API; they do not validate the tool’s output.
