Home » Free Tools » Free HTML Encoder & Decoder – Encode, Decode HTML Entities Online

Free HTML Encoder & Decoder – Encode, Decode HTML Entities Online

Free HTML Encoder & Decoder Online – Encode, Decode & Validate HTML Entities
Copied to clipboard!
Free Tool · WritoryBuzz

Encode special characters to safe HTML entities and decode them back. Supports named, decimal & hex entities, attribute-safe mode, XSS-safe encoding, and a full 250+ entity lookup, the most complete free encoder online.

Encode / Decode HTML

Encode → Minimal
Encoding mode:
Entity format:
Quick examples:
Supports plain text, HTML markup, mixed encoded strings, multi-line content.

📖 HTML Entity Reference — 250+ Entities

Click any entity to copy to input

What Is HTML Encoding?

HTML encoding is the process of converting characters that carry special meaning in HTML syntax into their safe entity equivalents. The five characters that must always be encoded in HTML text are & (→ &amp;), < (→ &lt;), > (→ &gt;), " (→ &quot;), and ' (→ &apos;). Failing to encode user-controlled input is the root cause of Cross-Site Scripting (XSS), the number one web application vulnerability.

The WritoryBuzz HTML Encoder / Decoder goes beyond simple five-character encoding. It supports four encoding modes, three entity output formats, smart double-decode detection, and an inline entity lookup for all 252 named HTML entities — features most competing tools omit entirely.

Encoding Modes Explained

ModeCharacters EncodedUse CaseSecurity Level
Minimal& < > " 'HTML text nodes, safe attributesStandard
Full (all non-ASCII)Everything outside ASCII 32–126ASCII-only output, legacy systemsHigh
Attribute-safeMinimal + / = ` and all control charsUser content in HTML attributesVery High
JS-string safeHTML + JS meta-chars (\\ <> / + =)HTML inside <script> blocksContext-specific

Named vs Decimal vs Hex Entities

All three forms are syntactically valid HTML5 and decode to the same character. Choosing between them is a matter of readability, system compatibility, and preference.

FormExample (ampersand)CoverageReadability
Named entity&amp;~252 official HTML named entitiesHigh — self-documenting
Decimal NCR&#38;Full Unicode range (1,114,112 code points)Medium
Hex NCR&#x26;Full Unicode rangeLow — useful for hex-familiar devs

HTML Encoding and XSS Security

Cross-Site Scripting (XSS) attacks inject malicious scripts into web pages viewed by other users. Proper HTML encoding is the primary server-side and client-side defence. However, encoding must be applied in the correct context — HTML encoding alone is insufficient when inserting data into JavaScript, CSS, or URL contexts.

✅ HTML Text Context (safe with minimal encoding)

Inserting user data between HTML tags. <p>{USER_INPUT}</p>

&lt; &gt; &amp; &quot;

✅ HTML Attribute Context (use attribute-safe mode)

Inserting data into tag attributes. <input value="{INPUT}">

&quot; &apos; &#x2F; &#x60;

⚠️ JavaScript Context (HTML encoding is NOT sufficient)

Data inside <script> blocks needs JSON encoding, not HTML encoding.

JSON.stringify(value)

⚠️ URL Context (use percent-encoding, not HTML encoding)

Query parameter values need URL encoding before HTML encoding.

encodeURIComponent() + HTML encode

OWASP Rule #1: Never insert untrusted data except in allowed locations. Rule #2: HTML-encode all untrusted data before inserting into HTML text. Rule #3: Attribute-encode all untrusted data before inserting into HTML attributes. Always apply the correct encoding for the insertion context — mismatched context encoding creates a false sense of security.

What Is HTML Decoding?

HTML decoding is the reverse process: converting HTML entity references back to their original characters. Browsers do this automatically when rendering HTML, but developers frequently need to decode encoded strings in server-side code, in email templates, in CMS content that has been double-encoded, or when inspecting data from APIs that return HTML-encoded JSON.

Common double-encoding problems

Double encoding occurs when content is HTML-encoded more than once, producing output like &amp;lt; instead of the intended &lt;. This happens frequently when:

  • CMS plugins encode content before storage and again on output
  • API responses contain HTML-encoded strings that are then embedded in HTML templates
  • Copy-paste from HTML source into a WYSIWYG editor that also encodes
  • Email marketing platforms double-encode special characters

The Smart Decode mode in this tool detects and fully unwinds multiple levels of encoding, producing clean plain text regardless of how many times the input was encoded.

HTML Entities Every Developer Should Know

CharacterNamed EntityDecimalCategory
&&amp;&#38;Essential
<&lt;&#60;Essential
>&gt;&#62;Essential
"&quot;&#34;Essential
'&apos;&#39;Essential
 &nbsp;&#160;Spacing
©&copy;&#169;Symbol
®&reg;&#174;Symbol
&trade;&#8482;Symbol
&euro;&#8364;Currency
£&pound;&#163;Currency
&mdash;&#8212;Punctuation
&ndash;&#8211;Punctuation
"&ldquo;&#8220;Punctuation
"&rdquo;&#8221;Punctuation
×&times;&#215;Math
÷&divide;&#247;Math
±&plusmn;&#177;Math
&ne;&#8800;Math
&rarr;&#8594;Arrow

Frequently Asked Questions About HTML Encoding

What is HTML encoding?+
HTML encoding converts special characters that have reserved meaning in HTML into their entity equivalents. The five characters that must always be encoded are & → &amp;, < → &lt;, > → &gt;, " → &quot;, and ' → &apos;. This prevents browsers from interpreting those characters as HTML markup and is the primary defence against Cross-Site Scripting (XSS) attacks.
What is the difference between named, decimal, and hex HTML entities?+
Named entities use human-readable names like &amp; or &copy;. Decimal numeric references use the Unicode code point in decimal like &#38; for ampersand. Hexadecimal references use the code point in hex like &#x26;. All three are valid HTML5 and decode to the same character. Named entities cover about 252 common characters; numeric references cover the entire Unicode range of over one million characters.
When should I use minimal encoding vs full encoding?+
Minimal encoding converts only the five reserved HTML characters. Use it for text node content and most HTML attributes on UTF-8 pages. Full encoding converts every non-ASCII character to a numeric entity, producing ASCII-only output. Use full encoding when transmitting through systems that don't reliably handle UTF-8, or when generating HTML for legacy email clients that have limited Unicode support.
What is attribute-safe HTML encoding?+
Attribute-safe encoding goes beyond minimal encoding to also encode single quotes, backticks, forward slashes, and equals signs — characters that can be exploited in HTML attribute injection attacks. The OWASP XSS Prevention Cheat Sheet recommends encoding all characters outside the alphanumeric range when inserting untrusted data into HTML attributes without quotes, and encoding & " ' when inside quoted attributes.
Does HTML encoding prevent XSS attacks?+
HTML encoding prevents XSS in HTML text and attribute contexts. However, it is not sufficient for JavaScript context (use JSON encoding), CSS context (use CSS escaping), or URL context (use URL percent-encoding). Always apply context-appropriate encoding. A common mistake is applying HTML encoding to data injected into a <script> block — HTML encoding alone does not neutralize JavaScript-executable characters in that context.
What HTML entities do most other encoders miss?+
Most basic online encoders handle only the five core reserved characters. They miss mathematical operators (&minus; &times; &divide; &plusmn;), typographic punctuation (&mdash; &ndash; &ldquo; &rdquo; &lsquo; &rsquo;), currency symbols (&euro; &pound; &yen;), directional arrows (&larr; &rarr; &uarr; &darr;), fractions (&frac12; &frac14; &frac34;), and the full set of 24 lowercase and uppercase Greek letters. This tool includes all 252 named HTML entities.
What is the difference between HTML encoding and URL encoding?+
HTML encoding converts characters to HTML entity references (&amp; &lt;) for safe use in HTML documents. URL encoding (percent-encoding) converts characters to %HH notation (%26 %3C) for safe use in URLs. They serve different contexts. A space in HTML text does not need encoding; in a URL it must be %20. An ampersand in a URL query string must be %26; in HTML text it becomes &amp;. For data used in both a URL and then placed in HTML, apply URL encoding first, then HTML encoding.
What is double encoding and how do I fix it?+
Double encoding happens when text is HTML-encoded more than once, producing output like &amp;lt; where &lt; was intended. It commonly occurs in CMS platforms that encode on save and again on display, or when API-returned HTML-encoded strings are embedded in HTML templates. The Smart Decode mode in this tool detects and unwinds multiple levels of encoding by recursively decoding until the output stabilizes, showing you the clean plain text that was originally intended.