|
Developer Utilities 100% Client-Side · 0 Bytes Sent to Server Instant In-Memory Execution

HTML-encode Text

Prevent XSS vulnerabilities and syntax errors by encoding HTML reserved characters into named entities (&, <, >, ", ').

Input Text / Markup
80 characters
Clean Result
127 characters

Step-by-Step Instructions

1

Paste Plaintext or HTML

Paste source text containing special characters, symbols, or HTML tags.

2

Select Encoding Standard

Choose Named HTML Entities (`&`, `<`, `>`), Decimal Numeric (`&`), or Hexadecimal Entities (`&`).

3

Configure Scope

Choose to encode only reserved HTML characters (`<`, `>`, `&`, `"`, `'`) or all non-ASCII characters.

4

Copy Encoded String

Copy the sanitized entity string ready for safe embedding in HTML documents.

Key Features & Capabilities

  • Converts special characters to standard W3C HTML5 named entities (`&amp;`, `&lt;`, `&gt;`, `&quot;`, `&apos;`)
  • Decimal (`&#NNN;`) and Hexadecimal (`&#xHH;`) numeric character reference (NCR) generation
  • Essential protection against Cross-Site Scripting (XSS) when rendering user-submitted text in HTML
  • Full Unicode multi-byte character entity encoding

Frequently Asked Questions

Why is HTML entity encoding essential for web security (XSS prevention)?

When displaying untrusted user input inside an HTML document, characters like `<` and `>` can allow an attacker to inject malicious `<script>` tags (Cross-Site Scripting / XSS). Encoding `<` as `&lt;` and `>` as `&gt;` forces the browser to render the characters as visible text without interpreting them as executable markup.

What are the five essential XML/HTML character entities?

The five core reserved entities are: 1) `&` to `&amp;` (Ampersand); 2) `<` to `&lt;` (Less than); 3) `>` to `&gt;` (Greater than); 4) `"` to `&quot;` (Double quote); 5) `'` to `&apos;` (or `&#39;` Single quote).

What is the difference between Named Entities and Numeric Character References (NCR)?

**Named Entities** use human-readable abbreviations (e.g., `&copy;` for ©). **Numeric Character References (NCR)** use the character's Unicode code point in decimal (e.g., `&#169;`) or hexadecimal (e.g., `&#xA9;`). NCRs are universally supported across all XML/HTML parsers even if a named entity is not defined in older HTML versions.

Should HTML attributes be encoded differently than body text?

Yes. Inside HTML attribute values (e.g., `<input value="...">`), double quotes must be encoded as `&quot;` and single quotes as `&#39;` to prevent an attacker from breaking out of the attribute string delimiter.

Discover complementary online tools in the same workflow.