HTML Entity Encoder
Encode text to HTML entities online — escape special characters like <, >, &, and " instantly in your browser. No install needed.
Updated April 2026
How the HTML entity encoder works
Paste, pick a mode, copy — three steps
1. Paste your text
Type or paste any string into the input field — plain text, a code snippet, or raw HTML.
2. Choose a mode
Essential (`& < > " '`), Named Entities, or Numeric — pick the one that matches your use case.
3. Copy the result
The encoded output updates live as you type — hit Copy or Shift+Enter to send it to your clipboard.
What this HTML entity encoder does
Three encoding modes, one tool
Essential mode
Encodes only & < > " ' — the minimum needed to prevent XSS, and the recommended mode for most cases.
Named entities
Covers accented letters, currency symbols, arrows, Greek letters and math symbols using their official HTML5 entity names.
Numeric entities (`&#…;`)
Converts every non-ASCII character to a decimal reference — maximum compatibility with older or strict parsers.
Runs entirely in your browser
No text is ever sent to a server — encoding happens locally in JavaScript, instantly.
Examples
When you'll need this tool
The most common scenarios people use it for
Preventing XSS
Before rendering user-supplied content in HTML, always encode it first — a <script> tag should show up as text, not execute.
Code examples in docs
Display raw HTML tags as readable text inside a <pre> block without the browser interpreting them.
Email templates
Encoding special characters avoids rendering glitches in Gmail, Outlook and Apple Mail.
CMS content input
Makes sure special characters survive the round trip from database to browser without breaking markup.
Sanitizing API responses
Check that your backend's encoding logic actually produces the output you expect before shipping it.
Which mode should you use? Start here
Confusing it with URL encoding
HTML encoding uses entities (< → <); URL encoding uses percent-encoding (< → %3C) — they solve different problems.
Over-encoding everything
Modern UTF-8 pages don't need Named or Numeric entities just for accented letters — Essential mode is enough in most cases.
Relying only on your framework
React, Svelte and Vue auto-escape in normal bindings — manual encoding is only needed with innerHTML or dangerouslySetInnerHTML.
Why encode HTML entities here
Everything runs in your browser via JavaScript — no text is ever sent to, stored on, or logged by a server.
Three modes cover everything from the minimal security baseline (Essential) to maximum compatibility with legacy parsers (Numeric), without needing to memorize which named entity maps to which character.
Frequently asked questions
HTML encoding replaces characters with entities (< becomes <) so they display safely inside a document. URL encoding uses percent-encoding (< becomes %3C) so characters survive transmission inside a URL. Use HTML encoding whenever you're inserting content into HTML markup, not a link.
References
Related Tools
- HTML Entity Decoder Developer Decode HTML entities to plain text online — unescape <, >, &, " and all named entities instantly in your browser.
- Base64 Encoder Developer Encode any text or string to Base64 instantly in your browser. Supports UTF-8, shows character count and output payload size. Free, no signup, 100% client-side.
- Image to Base64 Developer Upload any image and convert it to a Base64 data URL ready for HTML, CSS, or JSON — free online converter supporting PNG, JPEG, SVG, WebP. No server upload.
- URL Encoder Developer Encode any URL or text to percent-encoding instantly in your browser. Follows RFC 3986. Free, no sign-up required.
- Base64 Decoder Developer Free online Base64 decoder — decode Base64 strings back to plain text instantly in your browser. Validates input and shows decoded payload size.