ES
navigate Enter open Esc close
Web & Entity Encoding

HTML Entities Encoder & Decoder

Convert special characters to standard HTML entities (<, >, &, ", ') or decode entities back to plain text.

100% Client-Side Processing — Zero Server Uploads

All entity encoding and decoding operations run locally in your web browser. Your text snippets are never uploaded, logged, or stored remotely.

Conversion Result
// Conversion output will appear here...
Copied to clipboard!

What is HTML Entity Encoding?

HTML documents rely on specific characters—such as <, >, and &—as foundational syntax delimiters to define tags and element boundaries. When authors want to display these characters literally as visible text within a web page, the characters must be converted into standardized HTML entities.

Without entity encoding, a web browser encountering <div> inside a blog post or code block will attempt to parse it as an actual DOM element rather than printing the literal string <div>. Converting < to &lt; instructs the HTML parser to render the less-than symbol safely as plain character data.

The 5 Core HTML Special Characters

According to the WHATWG HTML specification, the five core characters requiring escaping in normal HTML body text and attribute contexts are:

Character Named Entity Decimal Entity Hex Entity HTML Context
& (Ampersand) &amp; &#38; &#x26; Starts an entity reference
< (Less Than) &lt; &#60; &#x3C; Opens an HTML element tag
> (Greater Than) &gt; &#62; &#x3E; Closes an HTML element tag
" (Double Quote) &quot; &#34; &#x22; Delimits HTML attribute values
' (Single Quote / Apostrophe) &#039; / &apos; &#39; &#x27; Delimits single-quoted attributes

HTML Entity Encoding vs. HTML Sanitization

It is essential to understand the technical boundary between entity encoding and sanitization:

Security note (OWASP guidelines): While entity encoding prevents text from being parsed as markup when injected into standard HTML body elements (<div>...</div>) or quoted attributes, it does not make untrusted data safe inside execution contexts such as JavaScript blocks (<script>), inline event handlers (onclick), CSS stylesheets, or URI attributes (href="javascript:..."). Different output contexts require dedicated contextual escaping.

Modern UTF-8 & Unicode Handling

In modern web development, documents use the standard <meta charset="UTF-8"> encoding. Under UTF-8, accented Latin characters (á, ñ, ü), symbols (, ©, ), emojis (😀, 🚀), and multilingual text (such as Chinese, Japanese, Arabic, or Cyrillic) are natively supported without needing conversion to numeric entities.

Our encoder specifically targets the syntax-sensitive delimiter characters (&, <, >, ", ') while preserving clean, readable UTF-8 text throughout your strings.

Understanding Double Encoding

When text that already contains HTML entities (such as &amp; or &copy;) is passed through an encoder, the leading ampersand (&) will naturally be transformed into &amp;, resulting in &amp;amp; or &amp;copy;. This is the correct, predictable behavior of a literal entity encoder. To avoid unexpected double encoding in your application pipeline, always ensure strings are encoded only once at the point of output.

Verified Conversion Example

Below is a verified example generated by this encoder's transformation engine:

Original Input (Raw Markup & Text)

<div class="notice">Tom & Jerry's "Adventure" <script>alert(1)</script></div>

Encoded Output (HTML Entity Representation)

&lt;div class=&quot;notice&quot;&gt;Tom &amp; Jerry&#039;s &quot;Adventure&quot; &lt;script&gt;alert(1)&lt;/script&gt;&lt;/div&gt;

Related Developer Utilities

Explore other specialized client-side developer tools in our suite:

Frequently Asked Questions

What is HTML entity encoding and why is it needed?

HTML entity encoding converts reserved markup delimiter characters—such as < (&lt;), > (&gt;), & (&amp;), " (&quot;), and ' (&#039;)—into their corresponding standardized entity strings. This ensures web browsers display them as literal visible text on the page rather than interpreting them as opening tags, closing tags, or attribute boundaries.

Does HTML entity encoding sanitize HTML or prevent all XSS attacks?

No. HTML entity encoding transforms special characters into text entities so they render harmlessly within standard HTML body text contexts. It does not sanitize malicious attributes or script code in execution contexts like JavaScript blocks (<script>), inline event handlers (onclick), CSS stylesheets, or dangerous URL schemes (href="javascript:..."). Sanitization requires a dedicated HTML sanitizer.

What is the difference between HTML entity encoding and URL percent-encoding?

HTML entity encoding converts characters into entity references (like &lt; or &amp;) for display within HTML documents. URL percent-encoding converts characters into percent-escaped byte sequences (like %3C or %26) for use in URI query parameters and network addresses. They serve distinct specifications and are not interchangeable.

Does this tool support decoding decimal and hexadecimal entities?

Yes. The Decode function parses named entities (such as &amp;, &lt;, &copy;), decimal numeric entities (such as &#38;, &#169;), and hexadecimal numeric entities (such as &#x26;, &#x1F600;) back into their original Unicode text characters.

Is my text or source code uploaded to any remote server?

No. All encoding and decoding operations run 100% locally in your web browser using client-side JavaScript. Your code snippets, passwords, or text inputs are never sent to our servers or stored in cookies/localStorage.

Share this tool

Help others by sharing this free tool.