HTML Entities Encoder
Escape markup characters, or turn every non-ASCII character into an entity such as é or é.
Processed locally in your browser/ Your data stays in your browser.
What is HTML Entities Encoder?
HTML entities let you write characters that would otherwise be read as markup (< for <, & for &) or that are hard to type or store (é, €, 😀). Escaping the five special characters is the basic defence against broken pages and injection when text is placed inside HTML.
This encoder has four modes: only the special characters & < > " '; special characters plus named entities for accents and symbols (with numeric fallback where no name exists); or decimal / hexadecimal numeric references for every non-ASCII character. It is a pure string conversion that never touches the DOM.
How does it work?
- Paste the text or HTML fragment to escape.
- Choose whether to escape only & < > " ' or also convert non-ASCII characters to named, decimal or hex entities.
- Copy the result into your template, or press Swap to decode entities back to characters.
Common use cases
- Showing a code sample such as <div class="x"> inside an HTML page or blog post.
- Making text safe for an HTML attribute value or email template.
- Producing ASCII-only HTML for a system that mishandles UTF-8.
- Converting © ™ € and accented names into entities for legacy CMS fields.
Examples
Try this input in the tool above:
<a href="/search?q=café & thé">Tom & Jerry's café — 5 €</a>
<a href="/search?q=café & thé">Tom & Jerry's café — 5 €</a>
Privacy
HTML Entities Encoder runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
Entity encoding protects text placed in HTML body or attribute context. It is not a complete defence for JavaScript, CSS or URL contexts, which need their own escaping.
Frequently asked questions
Which characters must always be escaped?
Ampersand (&), less-than (<) and greater-than (>) in text; also double and single quotes inside attribute values. The default mode handles all five.
Why is the apostrophe ' and not '?
' is not defined in HTML 4 and older browsers ignore it. ' works everywhere, so this tool uses it.
Do I need to encode accented letters?
Not if your page is served as UTF-8, which is the norm. Encoding them is useful for ASCII-only channels or when you cannot control the charset.
Related tools
HTML Entities Decoder
Turn <, é, € and 😀 back into the characters they stand for.
Encoding & Decoding
URL Encoder
Make any text safe for a URL: spaces, accents, ampersands and emoji become %XX sequences.
Encoding & Decoding
Unicode Escape Converter
Turn é, ☕ and 😀 into \u00E9, \u2615 and \uD83D\uDE00 (or another escape style) for source code, JSON or CSS.
Encoding & Decoding
HTML Formatter
Paste minified or messy HTML and get clean, consistently indented markup you can read and diff.
Developer Tools
Strip HTML Tags
Delete every tag from a piece of HTML and keep only the text, with your choice of line breaks and entity decoding.
Developer Tools
XML Escape
Make any text safe to place inside an XML element or attribute value.
JSON & Data
Text to Decimal Converter
Get the Unicode number of every character: "é" is 233, "世" is 19990 and 😀 is 128512.
Encoding & Decoding