Qgenx Tools

HTML Entity Encoder / Decoder

Encode and decode HTML entities (<, >, &, ", ') and numeric character references locally in your browser without XSS risk.

Runs in your browser
Encode
Mode
0
Converted
0
Input chars
0
Output chars

About this tool

Encoding maps &, <, >, ", and ' to named (&lt;) or numeric (&#60;) entities in a single regex pass. Decoding resolves common named entities plus decimal (&#N;) and hexadecimal (&#xH;) character references via String.fromCodePoint. Embed code examples inside HTML <pre> blocks cleanly.

How to use the entity encoder

  1. Paste HTML or plain text into the input box.
  2. Choose Encode to turn special characters into entities, or Decode to turn entities back into characters.
  3. Tick Numeric (&#38;#60;) if you need numbers instead of names, for systems that reject named entities.
  4. Copy the output, or use Swap to continue with the output as the new input.

Why HTML entities exist

Some characters have a special meaning in HTML. The less-than sign opens a tag, the ampersand starts an entity and quotation marks end attribute values. When you want these characters to appear as text, they must be written as entities such as &lt; for less-than, &amp; for ampersand and &quot; for a quotation mark. Without them, a browser may read part of your text as markup.

Entities also cover characters that are hard to type, such as a non-breaking space or a right arrow, which can be written as &nbsp; or &rarr;.

A worked example

Encoding the sample markup turns every angle bracket into &lt; and &gt;, and every ampersand into &amp;, so the code shows on the page instead of running. Decoding the same output returns the original markup exactly. The sample also includes a script with less-than and greater-than signs, which is a common cause of broken pages when it is pasted into a text field unencoded.

  • Encode a code snippet before pasting it into a blog post or a help article.
  • Decode a string copied from a web page source to read the real characters.

Who uses an HTML entity encoder

  • Web developers showing code samples on a page without it running.
  • Content editors pasting text from a word processor into a web form.
  • Email designers checking that special characters display correctly.
  • Support staff reading escaped text in logs and error messages.
  • Students learning how a browser reads markup.

Tips and common mistakes

  • Encode the ampersand first when you encode by hand. Otherwise &lt; becomes &amp;lt;, which shows the entity text instead of the character.
  • Decode carefully. Decoding markup you do not trust can turn text into live code if you paste it back into a page.
  • Named entities such as &rarr; need an HTML parser that knows them. The numeric option is the safer choice for old systems.
  • Attribute values need quotation marks escaped as &quot; as well as ampersands.
  • Your text stays in the browser. Nothing is sent to our server.

Frequently asked questions

When placing untrusted text inside HTML attributes like value="...", unescaped quotes allow attackers to break out of the attribute.

Related browser tools