W3docs

Tools

HTML Encoder / Decoder

Paste HTML into the source pane and choose how to convert it: encode special characters to numeric entities, decode them back, or escape tag characters for safe display in a code block.

About the HTML Entities Encoder / Decoder

HTML Entities Encoder / Decoder converts text between raw characters and HTML entity references, in four modes: Encode Entities, Decode Entities, Encode Tags, and Decode Tags. Encode Entities escapes <, >, &, both quote characters and every character from U+00A0 upward (accented letters, CJK, symbols and emoji, the last by full code point) into decimal numeric entities such as &#60;. Encode Tags only escapes the eight characters that can break HTML markup — &, <, >, ", ', the backtick, = and / — into a mix of named (&amp;) and numeric (&#39;) entities.

It also works as an HTML decoder. Decode Entities and Decode Tags run the same full decoder: decimal (&#60;), hex (&#x3C;) and named entities (253 of them, including &nbsp;, &copy;, &eacute; and &hellip;) all turn back into the characters they stand for. Decoding goes exactly one level, so &amp;lt; becomes &lt;, not <; run it again if the text was encoded twice. Unknown names, entities without the closing semicolon and invalid code points are left as written. Everything runs as plain string processing in your browser, so nothing you paste is sent to a server.

Use Encode Tags before dropping a code sample or user-submitted markup into a <pre>/<code> block, so the browser renders it as visible text instead of parsing it as a real tag. Use Encode Entities when you need an ASCII-safe payload for something like an email template or CSV export, since it flattens accented, CJK and emoji characters to &#NNN; too, not just markup-special ones.

Examples

Escaping a script tag with Encode Tagstext
Source:
<script>alert('xss')</script>

Result (Encode Tags):
&lt;script&gt;alert(&#39;xss&#39;)&lt;&#x2F;script&gt;

Only the eight tag-breaking characters change — the letters in alert, xss, and script are untouched. This is the form to use before dropping a code sample into a <pre> or <code> block.

Encode Entities escapes markup, quotes and non-ASCIItext
Source:
<p>"Café" 👍</p>

Result (Encode Entities):
&#60;p&#62;&#34;Caf&#233;&#34; &#128077;&#60;/p&#62;

Plain ASCII letters and spaces stay readable; <, >, quotes, the accented é and the emoji (as one code point, &#128077;) become decimal entities.

Decoding named, hex and decimal entitiestext
Source:
&amp; &#x2F; &#39; &copy; &eacute; &hellip; &amp;lt;

Result (Decode Entities):
& / ' © é … &lt;

All three entity forms decode in one pass. The last one, &amp;lt;, only loses one level and becomes &lt;.

Frequently asked questions

Why do I need to encode HTML entities in the first place?

Characters like <, >, and & have special meaning in HTML, so a browser parses a literal <div> inside a text string as a real tag rather than displaying the four characters <div>. Replacing them with entity references — &lt; (named) or &#60; (numeric) — tells the browser to render the literal character instead of treating it as markup.

What's the difference between encoding HTML entities and encoding HTML tags?

Encode Entities converts <, >, &, quotes and every character from U+00A0 upward (accents, CJK, emoji) into decimal entities like &#60;, leaving ASCII letters and digits alone. Encode Tags only escapes the eight characters that can break HTML markup (ampersand, angle brackets, quotes, backtick, equals sign, and slash), using named entities like &amp; where one exists.

Can this tool decode HTML entities like &nbsp; and &copy;?

Yes. As an HTML decoder it handles decimal (&#169;), hex (&#xA9;) and 253 named entities such as &nbsp;, &copy;, &eacute; and &hellip;. Both Decode Entities and Decode Tags use the same decoder, so either one reverses the output of either encode mode.

Why does decoding leave some entities like &amp;lt; partly encoded?

Decoding is exactly one level. &amp;lt; decodes to the text &lt;, which is correct for a string that was encoded twice; press Decode again to go one level further. Unknown entity names, entities missing their closing semicolon and invalid code points are left untouched.

Is it safe to paste sensitive HTML or source code into an online HTML encoder?

Yes. All four conversions run as plain JavaScript string processing in your browser tab. There's no network request, so pasted content is never uploaded anywhere.

Does HTML entity encoding handle emoji and other Unicode characters correctly?

Yes. Encode Entities escapes every character from U+00A0 upward by code point, so an emoji such as 👍 becomes a single &#128077; rather than a broken surrogate pair, and decoding turns it back into the same emoji.