🔤 HTML Entity Encoder & Decoder

Ad Space - Top (728×90)

Input Text

Result

Result will appear here...
Ad Space - Middle (728×90)

How to Use

This tool combines three utilities—HTML Entity encoding, URL encoding/decoding, and Unicode conversion—organized into tabs for quick access. Here is a detailed guide for each function:

HTML Entity encode/decode: The default tab is "HTML Entities." Paste the text you want to convert into the textarea. For example, code snippets containing <, >, or &. Click "Encode →" and the tool converts these characters into their corresponding entity references (e.g., &lt;, &gt;). Enable "Full encode" if you also want non-ASCII characters encoded. Enable "Use hex entities" to output &#x3C; instead of decimal &#60;. Click "← Decode" to reverse the process.

URL encode/decode: Switch to the "URL Encode/Decode" tab. Enter the URL or query parameter to encode, then click "Encode →" to get percent-encoded output (e.g., space becomes %20, Chinese becomes %E4%B8%AD). Enable "Use encodeURIComponent" for stricter encoding appropriate for parameter values rather than full URLs. Click "← Decode" to restore the original URL.

Unicode conversion: Switch to the "Unicode" tab. Enter any text and click "Escape →" to convert it to \uXXXX escape sequences. Enable "Uppercase hex" for uppercase output (e.g., \u4E2D), and "Pad to 4 digits" to ensure all code points are four hex digits. Click "← Unescape" to reverse the conversion.

Use Cases

Safe display of HTML source code: When writing technical blogs, documentation, or forum posts, you often need to show HTML code snippets on a web page. Pasting raw HTML will cause the browser to render it as actual markup. Use the HTML Entity encoder to convert the code into entity references before pasting, ensuring readers see the code text rather than rendered output.

URL parameter construction and debugging: When building web apps or calling REST APIs, data containing Chinese characters, spaces, or special symbols often needs to be passed as URL parameters. Manual encoding is error-prone. Use the URL encode/decode tool to quickly and accurately encode values, avoiding request failures or security issues caused by improperly escaped characters.

Cross-platform character handling: In JavaScript, JSON, or other environments that do not accept direct Unicode input, non-ASCII characters (like Chinese or Emoji) must be represented as \uXXXX escape sequences. The Unicode converter supports BMP characters as well as supplementary-plane characters such as Emoji (via surrogate pairs or \u{XXXXX} syntax), meeting the internationalization needs of developers.

Extended Knowledge

HTML Entity types: HTML entities are divided into named entities (e.g., &lt;) and numeric entities (e.g., &#60; or &#x3C;). Named entities cover only a predefined subset (~250 characters), while numeric entities can represent any Unicode character (over 140,000 code points). This tool uses named entities for common characters and converts all non-ASCII characters to numeric entities in full-encode mode.

RFC 3986 URL encoding standard: URL encoding follows RFC 3986, which states that URLs may only contain a subset of ASCII characters (unreserved: A–Z, a–z, 0–9, -, _, ., ~). Other characters must be UTF-8 encoded and then percent-encoded. The difference between encodeURI and encodeURIComponent is that the former preserves URL structural characters (e.g., /, ?, =), while the latter encodes them—making the latter more suitable for parameter values.

Unicode vs. UTF-8: Unicode is a character-set standard that assigns a unique code point to each character. UTF-8 is the encoding scheme that translates these code points into byte sequences. URL encoding uses the hexadecimal representation of UTF-8 bytes (e.g., the Unicode code point for "中" is U+4E2D, its UTF-8 encoding is E4 B8 AD, and its URL encoding is %E4%B8%AD). Understanding these layers helps you choose the correct encoding mode in this tool.

HTML Entity Encoding

What is HTML entity encoding?

HTML entity encoding converts special characters in HTML into their corresponding entity references. For example, &lt; represents < and &amp; represents &. This allows these characters to be safely displayed on web pages without being misinterpreted by the browser.

Common HTML Entities

&amp;& (ampersand)

&lt;< (less than)

&gt;> (greater than)

&quot;" (double quote)

&#39;' (single quote)

&nbsp; → non-breaking space

&copy; → © (copyright)

Named vs Numeric Entities

Named entities use names (e.g., &lt;), while numeric entities use Unicode code points (e.g., &#60; or hex &#x3C;). Numeric entities can represent any Unicode character; named entities only cover predefined characters.

What is HTML entity encoding?

HTML entity encoding converts special characters in HTML (such as <, >, &, ", ') into their corresponding entity references (such as &lt;, &gt;, &amp;, &quot;, &#39;), preventing these characters from being parsed as HTML tags or attributes by the browser.

What's the difference between HTML entity encoding and URL encoding?

HTML entity encoding is used to safely display special characters in HTML documents, using entity references starting with &. URL encoding is used to transmit special characters in URLs, using percent-encoding starting with %. They serve different purposes and should not be mixed.

Is my data safe? Does it get uploaded to a server?

Completely safe. This tool is a pure frontend application. All encoding and decoding operations are performed locally in your browser. Your data is never uploaded to any server.

Ad Space - Bottom (728×90)