HTML Entity Encoder

Encode special characters as HTML entities, or decode entities back to text.

How to use the HTML Entity Encoder

  1. Choose Encode or Decode.
  2. Paste your text or HTML. The result updates instantly.
  3. Choose the entity format and whether to encode non-ASCII characters, then copy the output.

About this tool

Characters like <, >, & and quotes have special meaning in HTML. To show them as text – for example when publishing a code sample – they must be written as entities such as < and & – exactly what this HTML entity encoder does. Getting this wrong breaks layouts and, with user-supplied content, can open the door to cross-site scripting.

This tool encodes text to entities (only the essential characters, or every non-ASCII character too) in named, decimal or hexadecimal form, and decodes any named or numeric entities back to readable text. Conversion happens live as you type.

Frequently asked questions

In text content, & and < must always be encoded. Inside attribute values, also encode the quote character used to wrap the attribute. Encoding > as well is good practice.

Both work in all modern browsers. Named entities (&copy;) are more readable; numeric ones (&#169;) work for every Unicode character, even those without a name.

Encoding user input before placing it in HTML text is a key defence, but different contexts (JavaScript, URLs, CSS) need different escaping. Use your framework's templating, which escapes by default.

Paste your text into the HTML entity encoder and choose Encode. Special characters such as <, >, & and quotes are replaced with HTML entities like &lt; and &amp;, so the browser shows them as text. To decode HTML entities, paste the encoded text and choose Decode.