Ttooleras
🏷️

HTML Entity Encoder/Decoder

Encoders & Decoders

Encode special characters to HTML entities (&, <, ", ©) or decode entities back to their literal characters.. Free, private — all processing in your browser.

HTML Entity Reference — click to insert
Advertisement

The HTML Entity Encoder Decoder converts between special characters and their HTML entity representations in both directions. HTML entities are text sequences like &amp; (ampersand), &lt; (less-than), &quot; (double quote), &copy; (copyright), or numeric forms like &#169; and &#x00A9;. They exist because some characters have special meaning in HTML (<, >, &) or are hard to type (€, •, ∞). Encoding text to entities makes it safe to embed in HTML; decoding back shows what the entities actually represent.

The tool handles all three entity forms: named entities (&copy;, &nbsp;, &rarr; — about 250 are defined in HTML5), decimal numeric entities (&#169;), and hex numeric entities (&#x00A9;). Encode mode converts any text to HTML-safe form by escaping special characters. Decode mode converts entities back to their literal characters. Selective modes let you encode only the essential characters (< > & \" ') for minimal escaping, or everything non-ASCII for maximum safety. Common use cases: preparing user input for display to prevent XSS, decoding emails or scraped HTML back to readable text, and generating HTML source with correct special-character handling.

HTML Entity Encoder/Decoder — key features

Two-way conversion

Encode text to entities or decode entities back to text in one tool.

Named and numeric forms

Handles &copy;, &#169;, and &#x00A9; — all three forms of the same character.

Encoding strategies

Minimal (just & < >), standard, or maximum (all non-ASCII) depending on your safety needs.

250+ named entities

Full HTML5 named entity list including Greek letters, arrows, and typographic marks.

XSS-safe encoding

Minimal mode matches the escaping strategies of React, Angular, and major templating engines.

Preview

See how the encoded text will render in a browser before using it.

Copy-ready output

One-click copy the encoded or decoded result for pasting into code or content.

Client-side only

Input text never leaves your browser — safe for sensitive content.

How to use the HTML Entity Encoder/Decoder

  1. 1

    Pick direction

    Encode text to entities, or decode entities back to text.

  2. 2

    Paste your content

    Drop the text or entity-laden content into the input.

  3. 3

    Set encoding strategy

    For encoding: choose minimal (essentials only), standard, or maximum (all non-ASCII).

  4. 4

    Review the preview

    See how the encoded text renders in a browser alongside the raw entity form.

  5. 5

    Copy

    One-click copy the result for pasting into your code or document.

Common use cases for the HTML Entity Encoder/Decoder

Web development

  • User input sanitization: Encode text from user input before embedding in HTML to prevent XSS attacks.
  • CMS content embedding: Convert special characters in CMS content to entities so they display literally rather than being parsed as markup.
  • Email HTML: Prepare content for HTML email templates where some email clients strip non-entity special characters.

Content processing

  • Decode scraped content: Convert HTML-encoded text from scraped pages back to readable form.
  • Email archive extraction: Turn entity-laden email archives into plain readable text.
  • Documentation cleanup: Decode raw HTML source pulled from exports to more readable form for editing.

Data interchange

  • XML vs HTML: Convert between HTML and XML-safe forms (some entities differ).
  • JSON embedding: Ensure special characters in JSON strings are entity-escaped where needed.
  • API payload cleaning: Strip or encode special characters in text fields before API submission.

HTML Entity Encoder/Decoder — examples

Essential escaping

Minimal encoding of HTML-dangerous characters.

Input
<p>Hello & welcome</p>
Output
&lt;p&gt;Hello &amp; welcome&lt;/p&gt;

Copyright symbol

Encoding a non-ASCII character.

Input
© 2026 Tooleras
Output
&copy; 2026 Tooleras
or numeric: &#169; 2026 Tooleras

Decoding

Entities back to literal characters.

Input
Tom &amp; Jerry said &quot;hi&quot;
Output
Tom & Jerry said "hi"

Mixed forms

Named and numeric entities handled together.

Input
&copy; by Don&#39;t &#x00A9; 2024
Output
© by Don't © 2024
(three entity forms all decoded)

XSS prevention

Encoding user input safely for HTML.

Input
<script>alert("XSS")</script>
Output
&lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;
(safe to embed in HTML)

Technical details

HTML entities serve two purposes: encoding characters that have special meaning in HTML (so they display as text rather than being parsed as markup), and encoding characters that are hard to type or may not survive certain encoding transitions.

Essential HTML entities (must be escaped in certain contexts):
- & → &amp; (ampersand starts every entity)
- < → &lt; (starts HTML tag)
- > → &gt; (ends HTML tag, less strict but recommended)
- \" → &quot; (in attribute values with double quotes)
- ' → &#39; or &apos; (in attribute values with single quotes; &apos; not in HTML 4)

Named entities: HTML5 defines about 250 named entities for symbols, Greek letters, arrows, and typographic marks. Common ones:
- &amp; (&), &lt; (<), &gt; (>), &quot; (\"), &apos; (')
- &copy; (©), &reg; (®), &trade; (™)
- &nbsp; (non-breaking space, U+00A0)
- &mdash; (—), &ndash; (–)
- &hellip; (…)
- &ldquo; (\") &rdquo; (\") &lsquo; (\u2018) &rsquo; (\u2019)
- &rarr; (→) &larr; (←) &uarr; (↑) &darr; (↓)
- &times; (×), &divide; (÷)

Numeric entities: any Unicode codepoint can be written as &#N; (decimal) or &#xN; (hex). &#169; and &#x00A9; both represent ©.

Encoding strategies:
- Minimal: escape only & < > (and \" in attributes). Produces the shortest output.
- Standard: also escape ' and other commonly problematic characters.
- Maximum: escape all non-ASCII to named or numeric entities for 7-bit-safe text.

Decoding strategy: regex replace for entities with a fast lookup table, plus numeric conversion for &#N; and &#xN; forms. Unknown named entities are left as-is (a forward-compatible strategy).

Security implication: encoding is critical for XSS prevention. Text from users must be encoded before inserted into HTML to prevent script injection. The correct context-aware encoding differs (HTML text vs attribute vs URL vs JavaScript), but for simple HTML embedding, entity encoding the essentials is sufficient.

Common problems and solutions

Double encoding

Encoding already-encoded text produces &amp;amp; from &amp;. This is a common bug in frameworks that escape automatically. Be aware of whether your input is raw or already escaped.

Ampersand forgotten

When manually escaping, people forget that & itself needs escaping to &amp;. Every & in HTML must be encoded unless it’s already the start of a valid entity. Many XSS vulnerabilities start here.

Context matters

HTML body, attribute values, URLs, and JavaScript contexts all require different escaping. Minimal HTML entity encoding is correct for HTML text; attribute values need quote handling; URLs need percent-encoding; JavaScript needs backslash-escaping.

Named entity typos

&copy (missing semicolon) is ambiguous in modern HTML — strict XML parsing rejects it. Always include the semicolon for portable HTML.

Unicode private use areas

Very obscure characters (private use or deprecated codepoints) may not have named entities and vary in display. Use numeric entities for guaranteed encoding, but test rendering.

XML vs HTML5 entities

XML only knows 5 named entities (&amp; &lt; &gt; &quot; &apos;). HTML5 knows 250+. Content intended for XML must use only the 5 or numeric entities.

Security false confidence

Entity encoding is necessary but not sufficient for security. Context-aware escaping, Content Security Policy, and input validation are all still needed. Never rely on a single encoding pass to fully prevent XSS.

HTML Entity Encoder/Decoder — comparisons and alternatives

Compared to framework-provided escaping (React, Vue, Angular auto-escape content), this tool handles ad-hoc content outside a framework. Use frameworks for application code; use this tool for one-off content prep.

Compared to writing a custom encoder, this tool handles all 250+ named entities and edge cases you might miss. For automated pipelines, use a well-tested library; for interactive encoding, this tool is faster.

Compared to URL-encoding or base64-encoding tools, this one is specifically for HTML — the encoding strategies are different for different contexts. Use the right tool for the right context.

Frequently asked questions about the HTML Entity Encoder/Decoder

What is an HTML entity?

An HTML entity is a text sequence like &amp;, &lt;, &copy; that represents a special character in HTML source. Entities are needed because some characters (like < and >) have structural meaning in HTML, and others (like © or ∞) are easier to type as entities than to insert directly.

When should I use HTML entities?

When you need to display a character literally that would otherwise be interpreted as HTML structure (showing literal < or >), or when you want to embed special characters in HTML source that might not survive encoding transitions. Modern UTF-8 HTML reduces the need for non-essential entities, but the essentials (& < > in body, " in attributes) are still critical for safety.

Do I need to encode ' apostrophe?

In HTML 4, no — &apos; was not valid. In HTML5 it is valid. In practice, &#39; is universally safe. You only need to encode ' in attribute values delimited by single quotes; in regular HTML body and double-quoted attributes, raw ' is fine.

What is the difference between numeric and named entities?

Named entities use a symbolic name (&copy; for ©). Numeric entities use the Unicode codepoint (&#169; decimal or &#x00A9; hex). Numeric works for any character; named works only for the ~250 defined in HTML5. Both produce the same visible character.

Is this tool safe for XSS prevention?

Using this tool to encode user-supplied content is a necessary safety step, but not sufficient alone. Use it as part of a defense-in-depth strategy: encode output, validate input, apply Content Security Policy, and use framework-provided context-aware escaping (like React’s automatic escaping).

How do I decode scraped HTML?

Paste the HTML-encoded text into the decoder. &amp; becomes &, &lt; becomes <, and so on. The decoder handles named entities, decimal entities, and hex entities automatically.

What happens to unknown entities?

The tool leaves unknown named entities as-is for forward compatibility. If a future HTML version adds a new entity that isn’t in the current dictionary, the literal text is preserved rather than mangled.

Is my input private?

Yes. All encoding and decoding happens in your browser. User input, email archives, or confidential HTML never leave your machine.

Additional resources

Advertisement

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →