FREE ONLINE TEXT TOOL

HTML Entity Encoder & Decoder

Encode special characters (<, >, &, ", ') into HTML entity references (Named, Decimal, Hexadecimal) or decode HTML entities back to raw characters.

Encode & Decode HTML Entities

Enter text or HTML code to convert entity encodings instantly.

0 Characters
0 Lines

What are HTML Entities?

An HTML Entity is a character sequence used in HTML and XML to represent reserved characters, invisible spaces, and symbols that are not readily available on standard keyboards. In HTML syntax, characters such as <, >, &, and " have structural meaning—they define HTML tags, attributes, and script blocks. If you want a browser to display an actual less-than sign rather than opening a new HTML element, the character must be written as an entity reference (such as &lt;).

Our free HTML Entity Encoder & Decoder gives you full control over character conversion. You can encode reserved characters into Named Entities (e.g., &amp;), Decimal Entities (e.g., &#38;), or Hexadecimal Entities (e.g., &#x26;), or decode entity-escaped markup back into raw, human-readable text.

How to Encode and Decode HTML Entities

  1. Enter Your Text or Code: Paste your HTML snippet, XML data, or raw text into the input box above.
  2. Choose Your Conversion Mode:
    • Encode (Named Entities): Converts reserved symbols into readable named references (such as &lt; and &copy;).
    • Encode (Decimal &#123;): Converts characters into numeric decimal entity references (such as &#60;). Ideal for XML where named entities are restricted.
    • Encode (Hex &#x7B;): Converts characters into hexadecimal numeric references (such as &#x3C;).
    • Decode Entities: Reverses entity codes back into raw HTML characters and symbols.
  3. Copy or Download: Click Copy Output to copy the converted markup to your clipboard, or click Download TXT to save the file.

Common HTML Entities Quick Reference Cheat Sheet

The table below provides a quick reference for the most essential HTML entities used in web development:

Character Description Named Entity Decimal Entity Hex Entity
& Ampersand &amp; &#38; &#x26;
< Less Than &lt; &#60; &#x3C;
> Greater Than &gt; &#62; &#x3E;
" Double Quote &quot; &#34; &#x22;
' Single Quote / Apostrophe &apos; &#39; &#x27;
  Non-Breaking Space &nbsp; &#160; &#xA0;
© Copyright Symbol &copy; &#169; &#xA9;
— Em Dash &mdash; &#8212; &#x2014;

Real-World Use Cases for HTML Entity Encoding

  • Displaying Code Snippets in Technical Tutorials: When publishing coding guides or developer blogs, enclosing raw tags like <div> directly inside text causes browsers to render them as DOM elements. Encoding them into &lt;div&gt; ensures the actual code snippet displays visibly.
  • Cross-Site Scripting (XSS) Prevention: Sanitizing and escaping untrusted user input before outputting it into an HTML template prevents malicious script injection attacks (such as <script>alert(1)</script> being executed).
  • XML and RSS Feed Validation: Strict XML parsers fail with fatal errors if text contains raw ampersands (&) or angle brackets. Encoding these characters into entity references guarantees XML well-formedness.
  • HTML Email Template Compatibility: Email clients (like Microsoft Outlook) handle complex Unicode characters inconsistently. Using numeric HTML entities ensures symbols like copyright (&copy;) or currency marks render consistently across all inboxes.
  • Decoding Scraped Markup: When scraping web pages or consuming third-party API data, text often arrives entity-encoded. The decode feature quickly restores natural human-readable sentences.

Named vs. Decimal vs. Hexadecimal: Which Should You Use?

Each entity format has specific technical strengths:

  • Named Entities: Easiest for humans to read and remember (e.g., &copy; for © or &trade; for ™). Supported across all modern HTML5 browsers.
  • Decimal & Hex Entities: Rely on Unicode code points (such as &#8212;). Because standard XML only recognizes five named entities (&quot;, &amp;, &apos;, &lt;, and &gt;), numeric decimal and hex entities are strictly required for XML, SVG, and RSS documents.

Looking for complementary encoding and text tools? Try our companion URL Decoder & Encoder, encode binary data with the Base64 Encoder, inspect byte values with the Text to Binary Converter, or strip HTML tags with the Text Cleaner.

Frequently Asked Questions

Which characters MUST be escaped in standard HTML?

The four essential characters that must always be escaped in HTML body text and attributes are: ampersand (& → &amp;), less-than (< → &lt;), greater-than (> → &gt;), and double quote in attributes (" → &quot;).

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

Named entities use mnemonic English words (like &lt;), making them easy for developers to recognize. Decimal (&#60;) and hexadecimal (&#x3C;) entities use the character's numerical Unicode code point, ensuring universal compatibility across XML, SVG, and legacy rendering engines.

Does encoding HTML entities prevent Cross-Site Scripting (XSS)?

Yes. By converting characters like <, >, and & into entity references, browsers treat user-supplied input as harmless text rather than executable markup or JavaScript.

Why does an unescaped ampersand (&) break HTML validators?

In HTML syntax, the ampersand character (&) is reserved exclusively to start an entity reference. When a browser encounters an isolated & followed by plain text, it attempts to parse it as an entity, triggering parsing warnings and validator errors.

Can this tool decode HTML entities back into regular characters?

Yes. Simply paste your entity-encoded HTML into the tool and click Decode Entities. All named, decimal, and hex entity codes are instantly converted back into readable characters.

Explore More Free Text & Conversion Tools

Fast, secure, and easy-to-use online text utilities built for creators and developers.

Aa

Text Case Converter

Convert text between UPPERCASE, lowercase, Title Case, Sentence case and Capitalized case.

Use Tool →
#

Character Counter

Count total characters with and without spaces, words, sentences, and lines in real-time.

Use Tool →
W

Word Counter Online

Accurately count words, unique vocabulary, characters, reading time, and word frequency.

Use Tool →
.!?

Sentence Counter

Count sentences accurately, calculate average sentence length and readability metrics.

Use Tool →
⏱

Reading Time Calculator

Estimate reading and speaking time based on custom WPM reading speeds.

Use Tool →
0x

Decimal to Hex Converter

Convert base-10 decimal numbers to hexadecimal format with prefix and padding controls.

Use Tool →
⇄

Text Reverser

Reverse text characters, word order, line order, or flip text upside down instantly.

Use Tool →
L

Letter Counter

Accurately count total letters (A-Z), vowels, consonants, and analyze letter frequencies.

Use Tool →
≡

Line Counter

Count total lines, non-empty lines, empty lines, and add line numbers automatically.

Use Tool →
🧹

Text Cleaner

Clean duplicate spaces, strip HTML tags, remove empty lines, symbols, and numbers.

Use Tool →
A-Z

Alphabetical Order Sorter

Sort lines or words alphabetically (A-Z / Z-A), remove duplicates, or sort by length.

Use Tool →
↵

Line Break Remover

Remove newlines, replace breaks with custom delimiters, and preserve paragraphs.

Use Tool →
Tt

Title Capitalization Tool

Convert text into proper title case following AP Style and Chicago style guidelines.

Use Tool →

Text Formatter

Format line prefixes, suffixes, paragraph indentations, and sentence spacing.

Use Tool →
␣

Whitespace Remover

Remove all spaces, collapse multiple spaces, trim lines, and remove tab characters.

Use Tool →
📊

Word Frequency Counter

Analyze word frequency counts, filter stop words, and sort vocabulary density.

Use Tool →
<>

HTML Entity Encoder

Encode special HTML characters into Named, Decimal, or Hexadecimal HTML entities.

Use Tool →
B64

Base64 Encoder

Encode UTF-8 text or strings into standard or URL-safe Base64 format.

Use Tool →
🔓

Base64 Decoder

Decode Base64 string data back to readable UTF-8 text with input error validation.

Use Tool →
🔗

URL Decoder

Decode URL-encoded strings, percent encodings, and parse query parameters.

Use Tool →
01

Text to Binary Converter

Convert plain text strings into 8-bit binary code (0s and 1s) with UTF-8 byte encoding.

Use Tool →