Genesis Forge
Genesis Forge › Free tools › Developer tools

HTML entities encode and decode

Escape < > & and quotes so text can be shown safely in HTML, or turn entities such as &amp; back into characters.

Runs in your browser. Nothing you enter is uploaded.

What it does

Some characters have a special meaning in HTML. To show them as text, they are written as entities: &lt; for <, &amp; for &, and so on. This tool escapes text for HTML and decodes entities back.

How to use it

  1. Paste the text or HTML.
  2. Press Encode to escape it, or Decode to turn entities into characters.
  3. Tick the extra option if you need every non-English character as a numeric entity.

Worked example

<p class="note">Tom & Jerry</p> encodes to &lt;p class=&quot;note&quot;&gt;Tom &amp; Jerry&lt;/p&gt;.

How it works

Encoding replaces five characters: & < > " and '. Decoding lets the browser’s HTML parser read the text as plain text content, which understands all named entities (&nbsp;, &copy;) and numeric ones (&#8377;). The text is never inserted into the page as markup, so scripts in it cannot run.

Questions

Why escape HTML at all?

If user-supplied text is put into a page without escaping, a <script> tag in it would run. Escaping is the basic defence against that.

Do I need to encode Telugu or Hindi letters?

No, as long as the page is served as UTF-8. Numeric entities are only needed for old systems.

What is &nbsp;?

A non-breaking space: a space that does not allow a line break.

Is my text sent to a server?

No. Everything runs in your browser. Nothing you type is uploaded or stored by us.

Related tools

All free tools →