1. Home
  2. Coding Tools
  3. HTML Entity Encoder / Decoder

HTML Entity Encoder / Decoder

Convert special characters like <, >, & and quotes into HTML entities to display code safely, or decode entities back into plain text.

Runs locally in your browser. Your files and data are never uploaded or stored.

About the HTML Entity Encoder / Decoder

In HTML, characters such as <, > and & have special meaning. If you want to show them as text, for example when publishing code snippets in a blog post, they must be written as HTML entities like &lt; and &amp;. The HTML Entity Encoder / Decoder converts them automatically.

Encoding user-supplied content is also a key defense against cross-site scripting (XSS). Enable Encode all non-ASCII characters to convert emojis and international letters into numeric entities for systems that only support ASCII. Decode mode understands named entities (like &copy; and &nbsp;), decimal and hexadecimal numeric entities.

Examples: when you need HTML entities

Suppose you want to show this line of code in a blog post:

<p class="note">Tom & Jerry</p>

If you paste it as is, the browser treats it as a real paragraph and the tags disappear. Encoded, it looks like this in your HTML source:

&lt;p class=&quot;note&quot;&gt;Tom &amp; Jerry&lt;/p&gt;

and readers see the original code exactly.

Common entities worth remembering

  • &lt; and &gt; for < and >
  • &amp; for &
  • &quot; for a double quote inside attributes
  • &nbsp; for a space that never breaks, for example between a number and its unit: 10&nbsp;kg
  • &copy; for ©

Typical uses

Writing tutorials, showing code in documentation, putting special characters into email templates, and cleaning up text that arrives full of entities from a database or an RSS feed (decode mode turns &#039; back into an apostrophe).

How to use the HTML Entity Encoder / Decoder

  1. Choose Encode or Decode.
  2. Paste your HTML or entity-encoded text.
  3. Optionally encode all non-ASCII characters.
  4. Copy the output.

Frequently asked questions

Which characters must be escaped in HTML?

At minimum, & and < in text, plus quotes inside attribute values. This tool also escapes > and apostrophes for safety.

Does decoding run any scripts?

No. Decoding uses a textarea element, which never executes HTML or scripts.

What is &nbsp;?

A non-breaking space, which prevents a line break between two words and is not collapsed like normal spaces.