Developer Tools

HTML Entity Encoder

Escape special characters for safe HTML rendering or decode entities back to text. Named and numeric entities supported, all processed locally in your browser.

100% in-browserNo signupFree forever

What makes this tool different

Named entities

Escapes the five key characters (&, <, >, ", ') to their named entities like &amp; and &lt;.

Numeric entities

Optional mode that converts characters to numeric entities like &#60; for maximum compatibility.

Real-time conversion

Encode and decode update live as you type, with no submit button.

Local and private

Runs 100% in your browser. Your HTML never leaves your device.

About this tool

HTML Entity Encoder: everything you need to know

HTML entities are how the web safely represents characters that have meaning in markup. When you need to display a '<' as text, or safely echo user input into a page, escaping it into an entity is non-negotiable — it is a core defense against XSS and broken layouts.

OpenToolLab's HTML entity tool escapes the key characters — ampersand, less-than, greater-than, double quote, and single quote — to their named entities, with an optional numeric-entity mode for maximum compatibility. The decoder works in reverse, turning entities like &lt; and &amp; back into their literal characters.

Conversion is instant and live as you type, making the tool ideal for preparing user-generated content for safe rendering, debugging templating issues, or cleaning up exported data. And it runs entirely in your browser, so even sensitive markup never leaves your device.

Why does escaping matter so much? Consider a comment form. If a user submits '<script>alert(1)</script>' and you insert that string into your page without escaping, the browser treats it as markup and executes it. That is a stored XSS vulnerability — the single most common way attackers compromise web applications. Escaping converts every angle bracket into an entity so the script renders as harmless text on screen while never being executed. This encoder does that transformation in one click.

The five characters that always need escaping are the ampersand, the less-than and greater-than signs, and double and single quotes. The ampersand is especially sneaky: it is itself the start of every entity, so a raw & can corrupt the entities that follow it. That is why escaping order matters — the encoder handles it correctly so your output is always valid HTML.

Named versus numeric entities is a practical choice. Named entities like &copy; and &trade; are human-readable and widely supported, which makes them great for hand-maintained templates. Numeric entities like &#169; and &#8482; work in every context, including environments with limited character support, and are commonly used by server-side templating engines in PHP, Java, and JavaScript. This tool offers both modes so you can match whatever your stack expects.

Server-side developers will recognize the same logic in PHP's htmlspecialchars, Java's StringEscapeUtils.escapeHtml, and JavaScript's textContent assignment. This tool produces the same result, which makes it a convenient cross-check when you are building a template or sanitizing output in a language you do not use every day.

FAQ

HTML Entity Encoder — frequently asked questions

What is an HTML entity encoder?

An HTML entity encoder converts characters that have special meaning in markup into their entity form. It turns & into &amp;, < into &lt;, and quotes into &quot; so the browser renders them as literal text instead of interpreting them as HTML.

What is the use of an HTML entity encoder?

It is essential for safely displaying user-generated content. By escaping input before inserting it into a page, you prevent it from being executed as markup — a core defense against stored XSS attacks — and you keep layouts from breaking on special characters.

Is the HTML entity encoder free to use?

Yes, completely free with no signup and no account. It runs 100% in your browser, so your HTML and text are processed locally and never transmitted to any server.

What is the difference between named and numeric entities?

Named entities use readable names like &amp; for &. Numeric entities use codes like &#38;. Both render the same character; numeric forms work everywhere, while named forms are more readable in source code.

When do I need to escape HTML?

Whenever you insert user-generated content into a page, escape it to prevent it from being interpreted as markup. This is a core defense against stored XSS attacks and broken layouts.