# HTML Entities Encoder & Reference Table

Encode and decode HTML entities and browse a complete reference chart of special characters and ASCII codes instantly for free.

---

- **Canonical URL:** https://dothecalculation.com/calculators/html-entities-calculator
- **Category:** Everyday utilities
- **Publisher:** Do The Calculation (https://dothecalculation.com)
- **Cost:** Free, no account or sign-up required
- **Privacy:** Runs entirely in the browser; inputs are never sent to a server
- **Methodology:** https://dothecalculation.com/methodology

---

## HTML Entities Encoder & Reference Table

Convert characters to HTML entities, decode entities back to plain characters, and search the complete reference list of entities and ASCII mappings.

- Decode HTML entities
- Encode HTML markup syntax symbols
- Filterable reference symbol list

## The Purpose of HTML Entities

HTML entities are specific character sequences that start with an ampersand (&) and end with a semicolon (;). They are used in web development to display characters that are either reserved in HTML syntax or cannot be typed directly using a standard keyboard.

For example, the characters `<` and `>` are reserved in HTML because they define the boundaries of tags (like `<div>`). If a developer writes `if (x < y)` directly in an HTML file, the browser will interpret `<y` as an unclosed HTML tag, breaking the page layout. To display these characters as text, they must be written as the HTML entities `&lt;` and `&gt;`.

Additionally, entities allow developers to write non-ASCII symbols, math operators, and typographic marks in source files without worrying about file character encoding issues.

## Named, Decimal, and Hexadecimal Entities

An HTML entity can be written in three distinct formats, all of which resolve to the same unicode character in the browser:

• Named Entities: Friendly mnemonic names that are easy to remember. For example, `&amp;` for ampersand, `&quot;` for double quote, and `&copy;` for the copyright symbol. Not all Unicode characters have named entities.

• Decimal Code Points: The character code represented in base-10 format, prefixed with a hash sign. For example, the ampersand is represented as `&#38;`.

• Hexadecimal Code Points: The character code represented in base-16 format, prefixed with a hash sign and an "x". For example, the ampersand is represented as `&#x26;`. Hexadecimal is standard for Unicode notations.

## Preventing XSS and Markup Injection

HTML entity encoding is a key defense mechanism against Cross-Site Scripting (XSS) vulnerabilities. XSS occurs when an application takes user input (such as a comment or username) and renders it directly on a page without sanitization.

If an attacker inputs `<script>maliciousCode()</script>`, a vulnerable application will execute the script. However, if the application runs the input through an entity encoder before rendering, the characters are converted to `&lt;script&gt;maliciousCode()&lt;/script&gt;`. The browser will display the raw code as safe text on the screen instead of executing it, neutralizing the injection attack.

## Unicode Standard and Modern Encoding

Historically, before the adoption of UTF-8, developers had to use HTML entities for every non-English character to prevent encoding corruption (mojibake) when pages were loaded on different systems.

With the universal adoption of UTF-8, which supports over 1.1 million characters, developers can write characters like `©`, `é`, or emojis directly in their HTML files. However, escaping reserved characters (`<`, `>`, `&`, `"`, and `'`) remains mandatory to prevent HTML parsing conflicts, making entity encoders an essential tool in every developer's toolkit.

## How to Use This HTML Entities Tool

Choose Encode to escape reserved markup characters in raw text, or Decode to convert entity syntax back into plain readable characters. Type or paste your content and the result updates instantly, with a Copy Result button for quick reuse.

Use the searchable Entity Reference Table below to look up a specific symbol by name, description, or code — click any cell to copy that entity format directly.

## Worked Example: Escaping a Line of HTML Markup

Encoding the raw markup `<div>Hello & welcome!</div>` produces `&lt;div&gt;Hello &amp; welcome!&lt;/div&gt;` — every reserved `<`, `>`, and `&` character is replaced with its named entity so the string can be safely displayed as text instead of being parsed as HTML.

Decoding that same escaped string in Decode mode reconstructs the original markup exactly, `<div>Hello & welcome!</div>`, confirming the round-trip is lossless.

## Related Calculators

This tool is part of a Text & Encoding Tools cluster. For other web-safe encoding tasks, see the [URL Encoder & Decoder](/calculators/url-encoder-calculator) and the [Base64 Text & File Converter](/calculators/base64-codec-calculator). For raw byte-level inspection, try the [Binary, Hexadecimal & ASCII Converter](/calculators/binary-hex-ascii-calculator).

## Frequently asked questions

### What are HTML entities and why are they needed?

HTML entities are special character strings starting with & and ending with ;. They are used to represent reserved HTML characters (like < and >) to prevent browsers from misinterpreting them as code tags, and to display characters not found on standard keyboards.

### What is the difference between named, decimal, and hexadecimal entities?

Named entities use mnemonic names (e.g., &lt;). Decimal entities use the base-10 unicode number (e.g., &#60;). Hexadecimal entities use the base-16 unicode value (e.g., &#x3c;). All three render identically in the browser.

### Which characters must always be escaped in HTML?

The five characters that must always be escaped to prevent syntax errors and XSS are: < (&lt;), > (&gt;), & (&amp;), " (&quot;), and ' (&#x27; or &apos;).

### What is the entity code for a non-breaking space?

The non-breaking space entity is &nbsp; (decimal &#160;). It creates a space character that prevents the browser from breaking or wrapping the line at that position, keeping words grouped together.

### If my website uses UTF-8 encoding, do I still need HTML entities?

Yes. While UTF-8 allows you to type characters like copyright (©) or accents directly in your code, you must still escape reserved syntax characters like <, >, and & to prevent HTML parsing conflicts.

### How do I encode HTML entities in JavaScript?

JavaScript doesn't have a built-in encode function, but you can create one by replacing reserved characters using a map or by creating a temporary DOM element, setting its textContent, and reading its innerHTML.

### How do I decode HTML entities in JavaScript?

To decode entities, you can create a temporary DOM textarea or div element, assign the encoded string to its innerHTML, and retrieve the decoded value using textContent or value.

### Do HTML entities have an impact on SEO?

No. Search engine crawlers understand HTML entities and decode them during indexing. Using entities has no negative impact on search engine rankings and ensures page parsing remains valid.

### Why do some browsers render HTML entities as question marks?

If a browser displays a question mark or a square box instead of the entity symbol, it means the font being used by the browser does not contain the glyph for that specific Unicode character code.

### Can I use named HTML entities in XML files?

XML only predefines five named entities: &lt;, &gt;, &amp;, &quot;, and &apos;. To use other named entities (like &copy;), you must declare them in the Document Type Definition (DTD), or use their decimal/hexadecimal unicode values instead.

## Related concepts

- **Character escaping** — Replacing special characters in string payloads with safe character sequences.
- **Unicode standard** — The universal character encoding standard that assigns a unique number to every character.
- **UTF-8 encoding** — A variable-width character encoding capable of encoding all 1,112,064 valid character code points in Unicode.

## Related guides

- [Understanding Calculator Formulas: How DTC Turns Inputs into Results](https://dothecalculation.com/blog/site-guides/understanding-calculator-formulas) — Understand how Do The Calculation formulas are presented, what the explanation blocks mean, and how to verify calculator logic before using a result in a real decision.

## Related calculators

- [URL Encoder & Decoder](https://dothecalculation.com/calculators/url-encoder-calculator) — Encode or decode URL components, parse query parameters into a structured grid, and analyze URL structures instantly for free.
- [Morse Code Translator & Audio Visualizer](https://dothecalculation.com/calculators/morse-code-calculator) — Encode and decode text to Morse code instantly with an interactive signal pulse timeline visualizer and per-character breakdown.
- [Base64 Text & File Converter](https://dothecalculation.com/calculators/base64-codec-calculator) — Convert text or files to Base64 encoding and decode Base64 strings back to their original format instantly with a file preview.
- [Binary, Hexadecimal, & ASCII Multi-Base Converter](https://dothecalculation.com/calculators/binary-hex-ascii-calculator) — Convert integers and strings between binary, hexadecimal, ASCII, and decimal formats instantly with this free online conversion tool.
- [Binary to Text & ASCII Translator](https://dothecalculation.com/calculators/binary-translator-calculator) — Translate binary code to readable ASCII text and vice versa, with a full bit-grid visualization showing each character encoding.
- [Markdown Editor & Live Previewer](https://dothecalculation.com/calculators/markdown-editor-calculator) — Write and edit Markdown syntax with a live side-by-side HTML previewer, formatting controls, and a handy cheat sheet, free to use.

---

_This calculator is for general educational and reference purposes only. Results are estimates and should not be used as the sole basis for critical decisions._

---

_Source: [Do The Calculation](https://dothecalculation.com/calculators/html-entities-calculator). Quote freely with attribution and a link to this page._
