Convert text to HTML entities
To show <div> on a page without the browser treating it as a tag, you have to write <div>. This tool does that conversion for a whole text: angle brackets, ampersands and quotes, plus accented letters and symbols that have a named entity.
Use it to publish a code sample in a tutorial or documentation, to prepare text for an HTML attribute, or to write accented characters in a form that displays correctly whatever the page encoding (old email templates, for instance).
How to use it
- Paste your text or code in the input box.
- Pick how quotes are handled in the option list.
- Click the encode button.
- Take the result with the copy button.
The three options
- ENT_COMPAT (default): double quotes become
", single quotes are left as they are. - ENT_QUOTES: both double and single quotes are converted. The single quote becomes
'. - ENT_SUBSTITUTE: neither double nor single quotes are touched.
In all three cases <, >, & and accented characters are converted.
| Input | Output |
|---|---|
<p class="x"> | <p class="x"> |
Tom & Jerry | Tom & Jerry |
© 2025 | © 2025 |
<a href='#'> (ENT_QUOTES) | <a href='#'> |
Common mistakes
- Encoding twice. The ampersand of an entity gets converted too: run
<through the tool again and it becomes&lt;, so the page shows "<" instead of "<". To strip the extra layer, run the text through Htmlentities decode online. - Encoding a whole page. Every tag is neutralised, including the ones you wanted to keep. Encode only the content that should be displayed. Once the code is in place, check the page with the HTML validator online.
- Wrong option for an attribute. If the attribute is delimited by single quotes, as in
title='...', choose ENT_QUOTES. Otherwise an apostrophe in the text closes the attribute too early. For a value that goes inside an address, such as anhrefparameter, use online URL encoding instead.
Frequently asked questions
Do accented letters still need encoding?
On a page declared as UTF-8, no: only <, >, & and quotes must be encoded. Writing é is still correct, and useful when you do not control the encoding of the medium.
How is this different from htmlspecialchars?
The PHP function htmlspecialchars only converts the characters that have a role in HTML. htmlentities, used here, also converts every character that has a named entity.
Is my text stored?
It is sent to our server over HTTPS for the calculation and is not saved.