GetFixMyFile

HTML Entity Encoder

Encode common HTML entities for safe text nodes, or decode them back. Not a full HTML sanitizer.

HTML entity encode / decode

Escape &, <, >, quotes for safe HTML text nodes, or decode common entities back.

Output

Which characters are escaped

Encode replaces five characters and nothing else. & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot;, and ' becomes &#39;. The sample <div class="x">A & B</div> encodes to &lt;div class=&quot;x&quot;&gt;A &amp; B&lt;/div&gt;. Letters, digits, and the rupee sign are left as themselves. The output is meant for an HTML text node or a quoted attribute. It is not a sanitizer: it does not remove script tags as elements, and it does not check URLs.

Decode recognises amp, lt, gt, quot, apos, and #39, each with a trailing semicolon. One pass is not a loop. &amp;lt; becomes &lt; because only &amp; is replaced on that pass. Decode again to get <. Unknown entities such as &nbsp; or &#160; are left unchanged. Named entities without a semicolon are left unchanged.

Encode and decode run as you type. There is no separate button. Use Encode before you drop a user string into HTML you will publish. Use Decode when a portal shows &amp; instead of &. Do not encode twice: &amp; becomes &amp;amp; and the page will show the entity instead of the ampersand. A name like O'Brien encodes the apostrophe as &#39;, so the attribute stays quoted. Hindi text and the rupee sign are not escaped.

How to use it

  1. Choose Encode or Decode. The output updates with the box.
  2. For a text node, encode the raw string, then put the result between tags.
  3. If you still see &amp;lt; after one decode, decode a second time.
  4. Copy the output. This does not make the string safe against every HTML context, only these characters.

The text stays in this browser tab. GetFixMyFile does not upload it, store it, or include it in analytics.

Questions

Why is the apostrophe &#39; and not &apos;?
Encode writes &#39;. Decode accepts both &#39; and &apos;. Either form is a single quote after a successful decode.
Does this remove JavaScript?
No. It only escapes the five characters. A string can still be dangerous in a URL, a script context, or an unquoted attribute. Do not treat the output as a full HTML filter.
Will ₹ or Hindi letters change?
No. Only & < > " and ' are replaced. Other characters stay as Unicode text.

Frequently Asked Questions