DevTools Logo

HTML Encoder/Decoder

HTML Encoder/Decoder

Convert special characters to HTML entities and back

Encode HTML

Convert special characters to HTML entities for safe display

HTML Entities Reference

&&
<&lt;
>&gt;
"&quot;
'&apos;
¡&iexcl;
¢&cent;
£&pound;
¤&curren;
¥&yen;
¦&brvbar;
§&sect;
¨&uml;
©&copy;
ª&ordf;
«&laquo;
¬&not;
®&reg;
¯&macr;
°&deg;
±&plusmn;
²&sup2;
³&sup3;
´&acute;
µ&micro;
&para;
·&middot;
¸&cedil;
¹&sup1;
º&ordm;
»&raquo;
¼&frac14;

Examples

Click an example to load it

HTML Tags
<div class="container">Hello & welcome!</div>...
<div class="container">Hello & welcome!</div>
JavaScript
const name = "John"; // Comment with "quotes"...
const name = "John"; // Comment with "quotes"
XSS Prevention
<script>alert("XSS")</script>...
<script>alert("XSS")</script>
Special Chars
Copyright © 2024 | Price: €50 | "Quoted" & 'single...
Copyright © 2024 | Price: €50 | "Quoted" & 'single'
URL Attributes
<a href="page.html?a=1&b=2">Click & go</a>...
<a href="page.html?a=1&b=2">Click & go</a>

Examples

Encode a tag and attribute quotes

Input
<div class="x">
Output
&lt;div class=&quot;x&quot;&gt;

Angle brackets and double quotes are all included in the encoder's named-entity map.

Encode symbols and an ampersand

Input
Copyright © 2024 & price €50
Output
Copyright &copy; 2024 &amp; price &euro;50

The built-in map includes copyright, ampersand, and euro entities while ordinary text and digits remain unchanged.

Decode mixed named entities

Input
&lt;p&gt;5 &lt; 10 &amp;&amp; &copy; 2024&lt;/p&gt;
Output
<p>5 < 10 && © 2024</p>

Every recognized named reference is replaced, including repeated ampersand entities.

About this tool

HTML Encoder/Decoder uses a built-in character map rather than an external entity library. Encode mode replaces ampersands, angle brackets, both quote characters, selected Latin-1 symbols, punctuation, arrows, and other listed symbols with named HTML entities. Because ampersand is encoded too, existing entity text is encoded again.

Decode mode reverses the same named entities and also accepts semicolon-terminated decimal and hexadecimal numeric character references. Unknown or differently cased named entities are left unchanged because matching is case-insensitive but the reverse-map lookup uses the exact entity spelling.

Conversion updates as the input or mode changes. The result can be copied, and Swap moves the current output into the input while switching between encode and decode. Encode mode also renders the encoded result as a preview, and built-in examples cover tags, scripts, special characters, attributes, math symbols, and arrows.

How to use

  1. Choose Encode or Decode

    Use Encode to turn supported characters into named entities, or Decode to turn supported named and numeric references back into text.

  2. Paste the input

    Enter plain text in Encode mode or entity text in Decode mode. The output refreshes immediately.

  3. Inspect the exact conversion

    Check quotes, ampersands, unsupported entities, and the encode preview. Use Swap to feed the result back into the opposite operation for a round trip.

  4. Copy the result

    Copy the complete output after confirming that HTML entity encoding is the correct escaping method for the destination context.

Use cases

Displaying HTML source as text

Encode angle brackets and ampersands so an HTML snippet can be shown instead of interpreted as markup.

Preparing quoted attribute values

Encode the supported quote and markup characters in a value before placing it in an HTML attribute, while still applying context-specific validation.

Reading entity-heavy content

Decode supported named or numeric references copied from HTML into a readable plain-text representation.

Checking entity round trips

Use Swap to encode and then decode a sample while verifying how the tool handles its supported character map.

Common mistakes

Mistake:Using HTML entity encoding for a JavaScript, CSS, or URL context.

Fix:Escape for the actual output context. HTML body text, HTML attributes, JavaScript strings, CSS values, and URLs have different encoding rules.

Mistake:Encoding text that already contains entities and unintentionally producing &amp;amp;.

Fix:Decode or otherwise normalize known entity text before encoding it again, and avoid repeatedly passing an already encoded result through Encode mode.

Mistake:Leaving quotes unencoded inside an HTML attribute.

Fix:This encoder maps both double quotes to &quot; and single quotes to &apos;. Keep the entity that matches the attribute delimiter and validate the complete attribute context.

Mistake:Assuming every HTML named entity or every capitalization variant will decode.

Fix:Decode mode only reverses names in the built-in map, plus decimal and hexadecimal numeric references. Unknown or differently cased names can remain unchanged, so inspect the output.

Frequently asked questions

References & standards