HTML Entity Encoder
Convert text into HTML-safe markup. Encode only the five special characters to display code or user input safely, or also encode every non-ASCII character for systems that cannot handle UTF-8. Choose named entities like ©, decimal references like © or hexadecimal references like ©.
How to use the HTML Entity Encoder
- Choose what to encode: special characters only, non-ASCII too, or everything except letters and digits.
- Choose named, decimal or hex entities.
- Type or paste your text.
- Copy or download the encoded output.
Features
- Encodes & < > " ' for safe HTML text and attributes
- Optional encoding of all non-ASCII characters
- Named, decimal or hexadecimal references
- Correct handling of emoji and characters outside the BMP
- Live output as you type
Benefits
- Show HTML or code snippets on a web page without them rendering
- Prevent markup injection when inserting text into templates
- Produce ASCII-only HTML for legacy systems
Frequently asked questions
Which characters must be escaped in HTML?
In text content & and < must be escaped; inside attribute values the quote character must be too. Escaping all five (& < > " ') is the safe default.
Why is the apostrophe encoded as ' instead of '?
' is not defined in HTML 4, so ' is used for maximum compatibility with older browsers and email clients.
Is entity encoding enough to prevent XSS?
It protects text placed in HTML content and quoted attributes. Values inside scripts, CSS or URLs need context-specific escaping as well.
Related tools
- QR Code Generator — Create QR codes for links, text, Wi-Fi, email, phone, SMS or contact cards, with custom colours, and download PNG or SVG.
- CSS Gradient Generator — Design linear, radial and conic CSS gradients with draggable colour stops and a live preview, then copy the CSS.
- URL Decoder — Decode percent-encoded URLs and query strings, handle + as space, unwrap double encoding and spot malformed sequences.
- URL Encoder — Percent-encode text or URLs in component, full-URL or form mode, and break any URL into its parts and query parameters.
- HTML Entity Decoder — Convert HTML entities like &, é, € and 😀 back into plain text, supporting all HTML5 named entities.
- Percentage Calculator — Work out X% of Y, what percent one number is of another, percentage change, or increase and decrease a value by a percent.