Developer

What Is HTML Encoding? Entities & Escaping Explained

HTML encoding means replacing characters that have a special meaning in HTML with codes called entities. Learn how HTML encoding works, why escaping prevents XSS and layout breaks, and how to encode and decode named, decimal, and hex entities. Applying these recommended techniques ensures high visual quality, faster page load speeds, and.

Awais 2 min readPublished
What Is HTML Encoding? Entities & Escaping Explained

HTML encoding means replacing characters that have a special meaning in HTML with codes called entities. A less-than sign starts a tag, an ampersand starts an entity, and quotes delimit attributes. When you want those characters to appear as text instead of being read as markup, you escape them. This guide explains what entities are, when you need them and the mistakes to avoid.

What HTML entities are

An entity is a stand-in for a character, written as an ampersand, a code, and a semicolon. The same character can usually be expressed three ways: a memorable named form, a decimal numeric form, or a hexadecimal numeric form. All three render identically in the browser.

Tom & Jerry <b>   becomes   Tom &amp; Jerry &lt;b&gt;

The © sign, three ways:
named: &copy;   decimal: &#169;   hex: &#xA9;

Why escaping matters

  • Security: escaping user input is a primary defense against cross-site scripting (XSS)
  • Correctness: an unescaped < or & can silently break your page layout
  • Display: showing code samples requires escaping the tags so they appear as text
  • Attributes: escaping quotes prevents user data from breaking out of an attribute
Tip: Escape based on context. The five characters & < > double-quote and apostrophe cover HTML text and attributes, but data placed inside script or style blocks needs different handling entirely.

Using the tool

Paste raw text to encode it into safe entities, or paste entity-laden HTML to decode it back into readable characters. Decode mode is great for cleaning up content scraped from a page or stored in a database where everything was over-escaped. All conversion runs privately in your browser.

Common mistakes

Do not double-escape: turning an already-escaped ampersand into a doubly-escaped one produces visible garbage on the page. Equally, do not rely on manual escaping for security in templates that already auto-escape, or you may end up with both. Understand whether your framework escapes for you, and let this tool handle the one-off conversions and debugging.

An entity reference cheat sheet

Entities you will actually need
CharacterNamed entityPurpose
&&amp;Escapes itself in text and URLs
<&lt;Shows markup as text
>&gt;Closes nothing when escaped
"&quot;Safe inside double-quoted attributes
'&#39;Safe inside single-quoted attributes
 &nbsp;Prevents line-break inside a phrase

Escaping inside attributes matters as much as in text: an unescaped quote can break out of a data-attribute and change how JavaScript reads your string. For anything user-supplied that will be rendered as HTML, escaping is the difference between displaying text and executing markup — this tool covers the six cases that cover almost every real bug.


Frequently asked questions

HTML encoding replaces special characters like <, >, &, and quotes with safe entities (&lt;, &gt;, &amp;, &quot;) so the browser shows them as text instead of interpreting them as markup.

Replace the < character with the entity &lt;. The encoder here does this automatically for every special character — and can go further by escaping all non-ASCII characters to numeric references.


Tools mentioned

More reading

View all guides
Free Developer Tools Online: 2026 Developer Toolkit & Guides
Developer

Free Developer Tools Online: 2026 Developer Toolkit & Guides

Explore 30+ free browser-based developer tools: JSON formatters, Base64 converters, cron generators, regex testers, SQL formatters, and hash generators.

3 min readPublished
CSS Border Radius: 15 Copy-Paste Examples
Developer

CSS Border Radius: 15 Copy-Paste Examples

15 modern CSS border radius examples: rounded cards, pills, circle avatars, asymmetrical organic blobs, and fancy 8-value border radius shapes.

3 min readPublished
Percent Encoding Reference Table (Every Character)
Developer

Percent Encoding Reference Table (Every Character)

Complete percent encoding ASCII reference table: quick lookup for spaces, slashes, ampersands, punctuation, and UTF-8 special characters in URLs.

3 min readPublished
URL Encoding Explained: %20 vs +, Reserved Characters & Rules
Developer

URL Encoding Explained: %20 vs +, Reserved Characters & Rules

Complete guide to percent encoding in URLs: learn when to use %20 vs +, how reserved characters like & and ? work, and how to avoid encoding bugs.

3 min readPublished
Cron Every Hour, Day & Midnight: All Daily Schedules
Developer

Cron Every Hour, Day & Midnight: All Daily Schedules

Master standard daily cron schedules: cron every hour, every day at midnight, twice a day, and custom hourly intervals with copy-paste examples.

4 min readPublished
Cron Expression Cheat Sheet — Copy-Paste Schedule Examples
Developer

Cron Expression Cheat Sheet — Copy-Paste Schedule Examples

Free cron expression cheat sheet with copy-paste examples for every 5 minutes, hourly, daily at midnight, weekdays only, and more.

5 min readPublished
Cron Every 10 Minutes — Syntax, Examples and Best Practices
Developer

Cron Every 10 Minutes — Syntax, Examples and Best Practices

Use the cron expression */10 * * * * to run jobs every 10 minutes, plus examples for common schedules and troubleshooting tips.

3 min readPublished
Why CSV Is Tricky to Parse: Delimiters, Quotes and Headers
Developer

Why CSV Is Tricky to Parse: Delimiters, Quotes and Headers

Why CSV files are harder to read correctly than they look, how to choose the right JSON shape, and the mistakes to avoid.

2 min readPublished