Skip to main content

HTML entity encoder and decoder

Turn special characters into HTML entities or restore them to readable text directly in your browser.

  • Clipboard
  • Export
Automate

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

HTML entity encoding turns characters that could be interpreted as markup into text references. Decoding reverses that process to recover readable characters from an escaped excerpt. Choose the action explicitly: an ordinary ampersand in a name or sentence cannot reliably indicate the intended direction. Results remain text in an output field rather than an active HTML page. Processing runs in your browser without sending the excerpt to a remote conversion service.

Encoding replaces five characters: & with &amp;, < with &lt;, > with &gt;, double quotes with &quot; and apostrophes with &#39;. Accented letters, symbols and emoji remain Unicode characters. This is useful for many HTML text contexts, but it does not turn every non-ASCII character into a named reference.

Decoding recognizes named HTML references and decimal or hexadecimal numeric references. Some historical spellings without a semicolon follow HTML compatibility rules; use a terminating semicolon for predictable input. Unknown sequences are not arbitrarily replaced with other characters. Literal text and any existing tags are neither executed nor removed.

Each execution decodes one layer. &amp;lt; becomes &lt;, rather than immediately becoming <. This prevents consuming several escaping layers without an explicit choice. Encoding an already written reference also escapes its ampersand: &lt; becomes &amp;lt;. That extra layer can be intentional when documenting the source spelling of an entity.

Escaping depends on the destination context. This tool does not sanitize an HTML document or independently secure a URL attribute, JavaScript fragment or CSS rule. Decoded text may become unsafe if another application later inserts it using innerHTML. Prefer text insertion or a dedicated sanitizer when handling untrusted content.

How to use this tool

  1. Supply the exact source text

    Paste or import the excerpt without first changing ampersands, quotes or semicolons. Their original spelling matters when diagnosing multiple encoding layers.

  2. Choose encoding or decoding

    Encode raw characters to represent HTML text; decode existing references to recover characters. This form never guesses the direction from its input.

  3. Check the destination context

    Inspect before copying or downloading the text output. Editing the source hides the previous result. Reset clears both the source and output.

Use cases

Show markup in an explanation

Encode a short example such as <b> so an HTML text context can display the tag instead of treating it as a formatting instruction.

Read an export containing references

Decode escaped labels or descriptions. This restores characters without stripping tags or converting an entire document into plain text.

Investigate double escaping

Compare one layer at a time when &amp; appears unexpectedly in an interface. Locate the step that already escapes a value before adding another conversion.

Examples

Encode an ampersand and angle brackets

The ampersand and both brackets become references. Letters and spaces remain unchanged; the output describes a tag without creating live markup here.

Input

Tom & Jerry <b>

Result

Tom &amp; Jerry &lt;b&gt;

Decode named, numeric and nested references

The named reference produces ©, the hexadecimal reference produces an emoji, and &amp;lt; loses only one layer to become &lt;.

Input

&copy; &#x1F600; &amp;lt;

Result

© 😀 &lt;

Tips and best practices

  • Do not decode repeatedly just because an ampersand remains. First check whether that remaining layer is deliberate.
  • HTML escaping is neither Base64 nor a character encoding change. UTF-8 text can contain both Unicode characters and HTML references.
  • Keep HTML attribute values quoted and apply the rules for the particular attribute, especially when it contains a URL.
  • Remove private details or tokens before publishing an excerpt, even though this tool processes it locally.

Sources and references

Frequently asked questions

Why does encoding &lt; produce &amp;lt;?

The input already contains the spelling of a reference whose ampersand needs escaping. That output can display &lt; literally in HTML documentation. Choose decoding when you want the character < instead.

Does decoding remove HTML tags?

No. It replaces references with characters. A literal tag remains written in the output text; this tool is neither a text extractor nor an HTML sanitizer.

Why are accents and emoji not converted to entities?

The encoder retains Unicode and escapes its five designated characters. It does not require ASCII-only output. The decoder can still read numeric references representing accented characters and emoji.

Can I use this to prevent every HTML injection?

Encoding is context-specific rather than a universal guarantee. URLs, scripts, styles and attributes need their own checks. Do not automatically insert decoded text into active HTML.

Related tools

Tools similar or complementary to this one.

Similar tools

Format HTML or remove ordinary comments locally while retaining text whitespace and script content. No page execution or upload is required.

DevelopmentUse this tool

Convert HTML into readable portable Markdown directly in your browser.

DevelopmentUse this tool

Encode text as Base64 or decode a Base64 string back to its original content.

DevelopmentFeaturedUse this tool