HTML Encoder🔒 100% local
Encode text as HTML entities. Privacy-first, no server uploads.
Related Tools
Takes text that is headed for an HTML document and swaps the five characters HTML treats as markup - the ampersand, both angle brackets and both straight quotes - for their character references, so a fragment displays as written instead of being read as markup. The ampersand is substituted first, so an entity the tool has just produced is not escaped a second time. The whole chain of replacements runs in this tab, so the fragment is never uploaded.
How to use it
- Paste the fragment that is headed for a page into the Input box.
- Press Encode.
- Copy from the Output box, or press Clear to start again.
- Paste the result where the text should appear as text, not where markup is expected.
Worked example
<div class="test">Hello & World</div>becomes<div class="test">Hello & World</div>Computed by running the shipped HtmlEncoderLogic: the ampersand is replaced first, so the entity it produces is left alone by the later rules.
AT&T <Tom> says "hi"becomesAT&T <Tom> says "hi"Apostrophes become ' as well, which is why a contraction in prose comes back looking heavier than the surrounding text.
When to use it
- You want to display a fragment of HTML as text inside a pre or code block in a tutorial.
- A CMS field rejects raw angle brackets and you need the entity spelling of an attribute value.
- You are assembling a template string by hand and want to see which characters carry meaning in HTML.
- A code sample has to survive being pasted into a page without the browser reading it as markup.
What it does not do
- Only those five characters are in scope. Text that is already encoded is escaped again, so an input containing & comes back as &amp;, and copying an already-encoded fragment through this tool double-encodes it.
- Encoding is not sanitisation. Escaped text displays as characters; it does nothing about a script that is already inside your page.
- Whitespace, accented letters and everything else pass through untouched, so the output is only as safe as the rest of the string it lands in.
- If you need a backtick converted as well, the HTML Escape tool on this site uses one rule more than this one.