HTML entity encoder and decoder


        
    

Examples

Input

<a href="x">Tom & Jerry</a>

Encoded

&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

HTML Guides & articles

Related tools

HTML decode and HTML encode online is often used together with URL decoder and URL encoder online, JSON formatter, validator and beautifier online, Regex tester: test a regular expression online when payloads, tokens, URLs, logs, or markup move through the same workflow.

HTML entity encoder and decoder

Encode and decode HTML entities for markup, attributes and text. DevToolGrid Online offers a free HTML decode and HTML encode online.

What are HTML entities?

HTML entities are codes such as &amp;, &lt; and &gt; that represent characters which would otherwise be treated as markup or are hard to type. Encoding text into entities is essential for displaying user content safely and preventing cross-site scripting (XSS); decoding turns entities back into the original characters.

How to encode or decode HTML entities

  1. 1 Paste text or markup into the input panel.
  2. 2 Choose named, decimal or hexadecimal entities, and special-only or all non-ASCII.
  3. 3 Click Encode to escape, Decode to unescape, or Strip tags to get plain text.
  4. 4 Beautify or minify markup, and use the sandboxed preview to see the result render.

Common HTML escaping mistakes

  • Not escaping user inputInserting raw user text into a page enables XSS. Always encode &, <, > and quotes before output.
  • Escaping in the wrong contextAttribute values, text nodes and URLs need different escaping. Quotes especially matter inside attributes.
  • Double encodingEncoding already-escaped text turns &amp; into &amp;amp;. Encode each value once for the right context.

Decode HTML entities in code

Decode HTML entities JavaScript

new DOMParser().parseFromString(s, "text/html").documentElement.textContent

html_entity_decode PHP

html_entity_decode($s, ENT_QUOTES | ENT_HTML5, 'UTF-8')

Node decode HTML entities

import { decode } from "html-entities"; decode(s)

C# decode HTML entities

WebUtility.HtmlDecode(s)

Decode HTML entities React

Decode to a plain string first, then render it normally

HTML entity decode JS (encode)

el.textContent = s  //  then read el.innerHTML

HTML encoder vs decoder

An HTML encoder converts characters into entities so text is safe to place in markup — it is the step that prevents XSS. An HTML decoder does the reverse, turning entities back into readable characters, which is useful when inspecting scraped or stored content. This tool does both, plus tag stripping, beautify and minify.

FAQ

Is this tool free?

Yes. The HTML entity encoder and decoder are completely free with no limits.

Can I decode HTML entities online here?

Yes. Paste text to decode HTML entities online in the browser. The same html entities converter also encodes, so convert HTML entities online in either direction.

What are HTML entities and why are they used?

They are character references such as &amp;amp; that let a document contain characters the parser would otherwise read as markup. What are character entities in HTML comes down to that one job.

Is my data sent to a server?

No. Encoding, decoding and the preview run locally in your browser; nothing is uploaded.

Does encoding prevent XSS?

Encoding output for the correct context is a key defence against XSS, though a full strategy also uses a content security policy and validation.

What is the difference between named and numeric entities?

Named entities like &amp; are readable; numeric ones like &#38; or &#x26; work for any character, even without a defined name.