InputsLive
Tool
Input
Result
Base64
Enter input above to get started.

Output is generated client-side in your browser. No data is transmitted to any server.

Results are estimates. Consult a professional.

What it does

What is an HTML entity encoder (and what this tool does)

An HTML entity encoder rewrites the handful of characters that have a special meaning in HTML so a browser shows them as plain text instead of treating them as markup. The characters <, > and & are how HTML starts tags and references; left raw inside your content, the browser tries to parse them and your page breaks. This HTML entity encoder / decoder does the translation both ways: the encode side escapes those reserved characters into safe entities, and the decode side turns entities back into the literal characters they stand for.

An entity is just an escape sequence: a name or number wrapped in & and ; that the browser swaps for one character when it renders the page. Writing &lt; in your source displays a literal < on screen, with no risk of it being read as the start of a tag. The tool above runs this conversion live as you type — paste text or markup on the left, pick encode or decode, and read the result on the right.

Escaping, not encryption
Entity encoding only changes how characters are written so the browser displays them literally. It hides nothing and secures nothing on its own — the encoded text is fully readable and reverses with the decode side.
Why it matters

Why you need to escape reserved characters

HTML reserves a small set of characters to build the document itself. A < opens a tag, a > closes one, and an & begins an entity reference. When the browser meets one of these, it assumes you mean the markup, not the literal symbol. So the moment your content contains one of them — a maths expression with 5 < 10, a company name like Tom & Jerry, a code sample full of tags — the browser misreads it.

  • Broken rendering. Text like a < b can swallow everything after the < as if it were an unfinished tag, so part of your page simply vanishes.
  • Corrupted output. An & followed by letters and a semicolon — R&D; — may be read as an entity and silently changed.
  • Injection (XSS). If untrusted text containing <script> reaches the page unescaped, the browser runs it as code rather than printing it. Escaping turns that tag into harmless visible text.

Escaping resolves all three at once. Replace each reserved character with its entity and the browser prints the symbol you meant — 5 &lt; 10 shows 5 < 10 — instead of trying to parse it. The HTML standard defines these reserved characters and the references that stand in for them.

The HTML Living Standard defines the syntax of tags, attributes, and character references, including the ambiguous-ampersand rule that makes a bare "&" risky in content.
Two formats

Named vs numeric HTML entities

Every character reference comes in two forms, and they are interchangeable. A named entity uses a human-readable keyword — &amp; for the ampersand, &lt; for the less-than sign. A numeric entity uses the character's Unicode code point instead: &#NN; in decimal, or &#xHH; in hexadecimal. The letter A (code point 65, hex 41) can be written as &#65; or &#x41;, and both render an identical A.

  • Named entities are readable but limited — only characters the HTML spec has named (a fixed list of around 2,000) can use them. &copy; gives ©, &nbsp; gives a non-breaking space.
  • Numeric entities work for any Unicode character, named or not, so they are the universal fallback. The decimal &#169; and hex &#xA9; both produce © with no name required.
  • The apostrophe is the classic split. &apos; was only added to the named list in HTML5, so this tool encodes a single quote as the numeric &#39; — which every browser, including old ones, understands.
This decoder resolves the named references amp, lt, gt, quot, apos and nbsp, plus every numeric reference in decimal (&#NN;) or hex (&#xHH;) form. Other named entities — like © or — — decode here only through their numeric equivalent (©, —), since they sit outside that named set.
Reference

The reserved characters and their HTML entities

These are the characters that must be escaped in HTML content, with the named and numeric references that replace them. The encode side of this tool handles the first five — &, <, >, " and ' — which is the set that actually breaks parsing or enables injection. The rows below them are common non-reserved entities you will meet when reading HTML.

CharacterNamed entityNumeric (decimal)What it is
&&amp;&#38;Ampersand — starts every entity reference
<&lt;&#60;Less-than — opens an HTML tag
>&gt;&#62;Greater-than — closes an HTML tag
"&quot;&#34;Double quote — ends a double-quoted attribute value
'&apos;&#39;Single quote — ends a single-quoted attribute value
(space)&nbsp;&#160;Non-breaking space — a space that never wraps or collapses
©&copy;&#169;Copyright sign — not reserved, but often entity-encoded
&mdash;&#8212;Em dash — a non-reserved character, encodable for safety

Named references and code points per the HTML Living Standard named-character-reference list. This tool escapes & < > " ' on encode; the other rows are reference entities you may encounter when decoding.

Example

A worked example: encoding a link

Example: escaping <a href="example.com">Click & go</a>

This is the tool's default input — a snippet of HTML markup you want to display on a page as text, perhaps inside a tutorial, rather than have the browser turn into a real, clickable link. Watch what each reserved character becomes.

Step 1 — Find the reserved characters

Scan the string for the five that need escaping. It contains two angle-bracket pairs (the opening <a> and the closing </a>), the two double quotes around example.com, and one ampersand in Click & go. There is no apostrophe here, so the &#39; rule never fires.

Step 2 — Replace each one with its entity

Each < becomes &lt;, each > becomes &gt;, each " becomes &quot;, and the & becomes &amp;. Every other character — the letters, the slash, the dot, the spaces — is left untouched.

Step 3 — Read the encoded result

The output is &lt;a href=&quot;example.com&quot;&gt;Click &amp; go&lt;/a&gt;. Dropped into a page, that renders on screen as the literal text <a href="example.com">Click & go</a> — visible markup, not a working link. The decode side reverses it exactly.

Markup shown as text, not run as HTML
Because the ampersand was escaped first, the browser never mistakes """ or "<" for the characters they encode — it prints them. That ampersand-first ordering is why encoding & before everything else matters.
How to use it

Encode vs decode: which side do you need?

The mode switch decides the direction. Encode goes from raw characters to entities — use it when you are writing content into an HTML page and need reserved characters to survive as text. Decode goes from entities back to characters — use it when you are reading HTML that someone has already escaped and want the original back.

  • Encode when you are embedding a code sample in a blog post, putting user-supplied text into a template, or pasting a value into a CMS field that renders as HTML. Anything with <, > or & needs it.
  • Decode when you have copied escaped HTML out of page source, an email template, or a database, and want to see the human-readable original — turning &amp; back into &.
  • Round-trip safely: encode then decode returns the exact input. The two operations are inverses, so you can move text in and out of HTML without losing or altering a character.
Where it's used

Real use-cases for entity encoding

Entity encoding shows up anywhere text crosses into an HTML context and has to keep its literal meaning. The common thread is the same in every case: the content contains a character the browser would otherwise read as structure.

  • Showing code in HTML. Tutorials, documentation and forums that display markup must encode it, or the examples would render as live elements instead of printed code.
  • CMS and template content. Titles or body text with an ampersand or angle bracket — Q&A, <3 — need escaping before they are written into a page so the CMS does not mangle them.
  • HTML emails. Email clients parse HTML strictly; an unescaped & or quote in a subject line or body can break the layout, so generated emails escape dynamic values.
  • Inserting user input. Comments, usernames and form data that get echoed back into a page must be encoded — both to display correctly and to block injection.
Security

Entity encoding as an XSS defense — and its limits

Escaping untrusted input before it lands in a page is one of the core defenses against cross-site scripting (XSS). If an attacker submits <script>steal()</script> and your page outputs it raw, the browser runs that script. Encode it first and the same input becomes &lt;script&gt;steal()&lt;/script&gt; — harmless text the browser displays rather than executes. That single step neutralises the most common injection path.

Context decides which escaping is enough
Escaping & < > " ' is sufficient for two contexts: HTML text content, and quoted attribute values (both quote styles, since the single quote is escaped too). It is NOT sufficient for unquoted attributes, or for data placed inside <script>, inline CSS, or a URL — those need their own context-specific escaping. Match the encoding to where the data lands.

So treat HTML entity encoding as necessary for the HTML body and attribute context, not as a complete XSS solution by itself. The standard guidance is to encode on output, encode for the exact context, and pair it with other controls. Most modern frameworks — React, Vue, Angular — entity-encode text bindings automatically, which is why their default rendering is safe; the danger returns the moment you bypass that with a raw-HTML escape hatch.

OWASP's XSS Prevention Cheat Sheet sets out output encoding by context — HTML body, attribute, JavaScript, CSS, and URL — and why HTML-entity encoding alone does not cover every one of them.
Privacy

Does this encoder send my text anywhere?

No. The encoding and decoding run entirely in your browser with plain string replacement. The text you paste is never stored, logged, or sent to any server — there is no network request, because none is needed — so the tool works the same offline and your content stays on your device.

Because it only rewrites characters, entity encoding is not a security control for your data and should never be confused with encryption: the output is fully readable and reverses instantly. For other transport-safe formats, see the URL encoder / decoder, which percent-encodes text for web addresses, and the Base64 encoder / decoder for binary-safe text.

Definitions

HTML entity definitions

An escape sequence that stands in for one character, written as a name or number between "&" and ";". The browser swaps it for the character when it renders the page, so "&lt;" displays a literal "<".
One of the characters HTML uses for its own syntax — & < > and the quote marks. They must be escaped in content so the browser prints them instead of treating them as markup.
A character reference that uses a keyword, like &amp; or &nbsp;. Readable but limited to the characters the HTML spec has named.
A character reference that uses the Unicode code point — &#NN; in decimal or &#xHH; in hex. Works for any character, which makes it the universal fallback.
An entity for a space that does not wrap to a new line and is not collapsed with neighbouring spaces. Used to keep words or values together on one line.
An attack where malicious markup or script is injected into a page through unescaped input. Entity-encoding output is a core defense, applied per the context the data lands in.
Accuracy

How reliable is this HTML entity encoder?

The conversion is exact. On encode, the five reserved characters & < > " ' are replaced with the entities defined by the HTML standard — the single quote as the numeric ' for the widest browser support — and every other character is passed through unchanged. On decode, the named references amp, lt, gt, quot, apos and nbsp resolve, along with any numeric reference in decimal or hex. Encode then decode returns your input character for character.

The one judgement the tool cannot make for you is context. It escapes the characters that matter for HTML body and attribute output; whether that is the right encoding for where your data lands — an HTML element, an attribute, a script, a URL — is a decision only you can make, and for non-HTML contexts you may need percent-encoding via the URL encoder or another scheme instead.

Questions

Frequently asked questions about the free HTML entity encoder / decoder

A HTML entity encoder calculator is a free online tool that helps you escape HTML special characters or decode entity references — safe for output and XSS prevention. HTML reserves <, >, &, ", ' — they must be escaped as named entities in output to prevent rendering or XSS. It runs entirely in your browser with instant results and no sign-up.
Unescaped user input lets attackers inject HTML / JavaScript (XSS). Encoding turns dangerous tags into text instead of executable markup.
& and < are always required. > is required in CDATA / safe contexts. The quote chars are required inside attributes — depends on quote style.
Characters above U+00A0 don't strictly need escaping in UTF-8 documents but can be encoded for safety. Most modern setups serve UTF-8 directly.
About

About this HTML entity encoder / decoder

This HTML entity encoder / decoder runs entirely in your browser. The text you paste is never stored, logged, or sent to any server — the escaping is computed locally with plain string replacement, so it works the same offline. Encode escapes the reserved characters & < > " ' for safe HTML output; decode turns named and numeric entity references back into the characters they stand for. It only changes how characters are written; it is not encryption and hides nothing.

Looking for more developer utilities? Try the URL encoder or the Base64 encoder, or browse the rest of our dev tools.

Want a calculator built for your business?

Customize any of our 400+ tools to match your brand, or commission a new one tailored to how your business actually calculates — pricing, payroll, quotes, anything. Deployed on your domain, math runs in your visitors' browsers.