HTML Entity Encoder
Escape <, >, & and quotes into HTML entities so code displays as text instead of rendering.
The five characters it replaces
| Character | Becomes |
|---|---|
& | & |
< | < |
> | > |
" | " |
' | ' |
Those are the characters that can end a tag or an attribute value early. The sample shows all of them at work:
Nothing else changes. Accented letters, symbols, emoji, tabs and line breaks pass through as they are: Café © 2026 — 5 > 3, it's becomes Café © 2026 — 5 > 3, it's. On a page served as UTF-8 that is all you need.
Text that is already encoded gets encoded again
The encoder doesn't recognise existing entities. Every ampersand is escaped, including the one at the start of an entity:
On a page, that shows the reader the literal text &. If the result looks like that, the text was encoded twice somewhere, perhaps once by your CMS and once here. Encode raw text exactly once, at the point where it goes into the HTML.
Putting code on a page
The usual job for this tool is showing a snippet as text, for example in a tutorial. Encode it, then place it inside <pre><code>:
Running that through the HTML Entity Decoder gives back the original line character for character, so you can check a snippet before publishing it.
Where encoded text is and isn't safe
Encoded text is safe between tags and inside a quoted attribute value, because it can no longer open a tag or close the quotes. It doesn't make a value safe everywhere:
- Inside a
<script>block the browser doesn't decode entities, so use JavaScript string escaping there. - In a link's URL, a
javascript:address still runs after encoding, because it contains none of the five characters. Check the scheme instead. - For query string values, use percent-encoding with the URL Encoder.
Frequently asked questions
Why does the apostrophe become ' and not '?+
The numeric form works in every version of HTML and in XML, while the named form was not part of HTML 4. Browsers display both as the same apostrophe.
Does it turn spaces into ?+
No. Spaces, tabs and line breaks are left untouched. Whitespace inside a pre element is shown as typed; elsewhere the browser collapses runs of spaces.
Can I convert accented letters to named entities like é?+
Not with this tool. It only escapes the five markup characters and leaves letters like é as they are, which displays correctly on any page served as UTF-8.
Embed this tool on your website
Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.
<iframe src="https://utilityapp.lat/embed/convert/html-encode" title="HTML Entity Encoder" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe> <p style="font-size:13px"><a href="https://utilityapp.lat/convert/html-encode">HTML Entity Encoder</a> by UtilityApp</p>