Embed this tool on your site
About this tool
HTML entities are the escape mechanism that allows special characters to appear in HTML without being interpreted as markup. The less-than sign (<) becomes <, the ampersand (&) becomes &, and quotation marks become " or ' — each encoding prevents the browser from treating the character as HTML syntax. This encoder/decoder has two entity modes. Named / Basic encodes the five reserved characters plus the non-breaking space (& < > " ' ) and decodes those names plus any decimal or hex numeric entity. Numeric encodes the reserved characters, control characters such as newlines, and every non-ASCII character as decimal codes like ©, and decodes decimal (©) or hex (©) entities. Other named entities such as © and — are left as they are when decoding. Pick Encode or Decode, click Run, and use Swap to feed the output back in. Everything runs in your browser.
Why use it
Prevent XSS in HTML Output: Encoding user-supplied text before inserting it into HTML prevents cross-site scripting attacks where injected script tags execute in visitors' browsers.
Readable Named Escapes: Named / Basic mode turns & < > " ' and the non-breaking space into & < > " ' and , leaving all other characters untouched so the text stays readable.
Quotes Always Escaped: Both double and single quotes are encoded in every encode mode, so the output is safe inside quoted attribute values as well as text nodes.
Decode CMS and Template Output: Recover plain text from HTML sources that add unnecessary escaping — basic names and all decimal or hex numeric entities are decoded.
Non-ASCII to Numeric Entities: Numeric mode encodes accented letters, emoji, symbols and CJK as decimal entities such as © and 😀 for ASCII-only email or legacy templates.
Instant In-Browser Processing: No server round-trip — encoding and decoding runs client-side so your text content stays completely private.
How to use
- Choose the Action: Encode (plain text → HTML entities) or Decode (HTML entities → plain text).
- Choose the Entity mode: Named / Basic for & < > " ' , or Numeric for decimal &#N; codes.
- Paste your text into the Input area.
- Click Run to produce the output.
- Click Copy to copy the result, or Swap to move the output back into Input for another pass.
- Click Clear to empty both boxes and start again.
When it helps
- When embedding user-generated content in HTML and needing to escape it before inserting it into a template to prevent XSS vulnerabilities.
- When writing inline HTML in a CMS, email builder, or static site generator that interprets < and & as markup syntax rather than literal characters.
- When inserting a code snippet or command containing angle brackets into an HTML page and needing the characters to display literally.
- When debugging double-encoded output from a templating engine where < appears in the browser instead of the intended < character.
- When preparing text for an HTML attribute value that contains quotes, ampersands, or special characters that would break the attribute syntax.
- When converting a plain-text legal or technical document containing characters like © ™ — into their HTML entity equivalents for proper rendering.
Examples
01Encode code snippet for display in HTML (Named / Basic)
Input<script>alert('XSS & injection');</script>
Expected result<script>alert('XSS & injection');</script>
02Decode entity-heavy CMS output (Named / Basic)
Input<h1>Café & Bar</h1><p>Your "all-in-one" toolkit © 2026</p>
Expected result<h1>Café & Bar</h1><p>Your "all-in-one" toolkit © 2026</p>
03Encode special characters for email template (Numeric)
InputCopyright © 2026 — All rights reserved. Price: $19.99 & free shipping.
Expected resultCopyright © 2026 — All rights reserved. Price: $19.99 & free shipping.
Tips
- Always encode at minimum the five unsafe characters (&, <, >, ", ') when inserting any user-supplied or external text into HTML, even if it looks safe — defense in depth prevents XSS.
- Use the decode direction to quickly read what a heavily entity-encoded string will actually display as in a browser without needing to open a separate HTML file.
- Inside an href or other attribute, write a literal & in a URL query string as & — browsers decode it back to & before following the link.
- Non-breaking space ( ) is one of the most overused entities — replace any used purely for indentation or layout with CSS margin/padding for cleaner, more maintainable markup.
- Paste a snippet of your template output into the decoder to diagnose double-encoding issues — if the decoded output still contains entity sequences, your pipeline is encoding already-encoded text.
Frequently Asked Questions
What are HTML entities and why are they needed?⌄
HTML entities are text replacements for characters that have special meaning in HTML syntax. The < and > characters delimit tags, & starts entity references, and " and ' delimit attribute values. If these characters appear unescaped in HTML content, browsers may misinterpret them as markup. Encoding them (e.g. < becomes <) tells the browser to display the character literally.
What is the difference between the named quot entity and numeric #39?⌄
" is the named entity for the double-quote character (") and is valid in HTML4 and HTML5. ' is the numeric entity for the apostrophe/single quote (') — HTML4 has no named entity for it, though ' was added in HTML5. This tool writes ' when encoding and decodes both ' and '.
Should I encode all characters or only unsafe ones?⌄
For security you must encode at minimum & (&), < (<), > (>), " (") and ' (') — that is what Named / Basic mode does. For ASCII-limited environments like older email templates, Numeric mode also encodes every non-ASCII character (© becomes ©). Note that Numeric mode encodes newlines too ( ).
What is double encoding and how do I detect it?⌄
Double encoding occurs when already-encoded entities are encoded again — for example, < becomes &lt;, which renders literally as < in the browser instead of <. If you see entity text like &amp; or < on the rendered page, something in your pipeline is encoding input that was already encoded. Decode once to recover the intended text.
Does encoding HTML entities protect against SQL injection?⌄
No. HTML entity encoding only protects output that is rendered in HTML contexts (browsers). For database queries, use parameterized queries or prepared statements — these operate at the SQL layer and are unaffected by HTML encoding. Never rely on HTML encoding as your only defense for database-bound input.
What is the entity and when should I use it?⌄
represents a non-breaking space (Unicode U+00A0). Use it to prevent line-breaks between two words that should stay together (e.g. 10 km, Fig. 1). Named / Basic mode encodes a real non-breaking space character as and decodes back to U+00A0.
Does the decoder understand ©, — and other named entities?⌄
No. Decoding recognizes only & < > " ' ' and by name, plus any decimal (©) or hexadecimal (©) numeric entity. Other names such as © or — are left unchanged in the output.
Can I use this tool to sanitize HTML from untrusted sources?⌄
Encoding converts characters to entities but does not remove HTML structure. If you paste actual HTML with tags into the encoder, the tags themselves are encoded as text. This tool is for encoding plain-text content for safe insertion into HTML — it is not a full HTML sanitizer. For sanitizing rich HTML from untrusted sources, use a library like DOMPurify.
Glossary
- HTML Entity
- A sequence of characters that represents a single character in HTML. Entities begin with & and end with ; and are used to display reserved characters or characters not easily typed. Example: < represents <.
- Named Entity
- An HTML entity identified by a human-readable name rather than a number. Examples: & (ampersand), © (copyright symbol ©), — (em dash —). Named entities are defined in the HTML specification.
- Numeric Entity
- An HTML entity expressed as a Unicode code point number. Decimal format: © (©). Hexadecimal format: © (©). Numeric entities work in both HTML and XML contexts.
- XSS (Cross-Site Scripting)
- A web security vulnerability where an attacker injects malicious scripts into content served to other users. Proper HTML entity encoding of user input is the primary defense when inserting data into HTML context.
- Non-Breaking Space ( )
- Unicode character U+00A0. Unlike a regular space, it prevents a line break at its position and is not collapsed when multiple spaces appear adjacent in HTML source.
- Character Reference
- The formal HTML term for what is commonly called an entity. A character reference can be named (&) or numeric (&) and always resolves to a single Unicode code point.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities