We use cookies

We use cookies and similar technologies to enhance your browsing experience, analyze site traffic, and personalize content and ads. By clicking "Accept", you consent to our use of cookies. Learn more in our Privacy Policy.

Free · in your browser · no signup

HTML Entity Encoder & Decoder

Encode special characters to HTML entities (or decode them back) so your markup renders safely — instantly, in your browser.

This is a free, in-browser tool for converting text to HTML entities and back. Encoding replaces characters that have special meaning in HTML, such as <, >, &, and quotation marks, with their entity equivalents like <, >, &, and ". Decoding reverses the process, turning entities back into the literal characters they represent. You can paste a snippet, switch direction, and copy the result.

The practical reason to do this is to keep markup valid and safe. When user-supplied or dynamic text is dropped into a page without encoding, an unescaped < can start a tag the browser wasn't meant to render, and an unescaped & can break an entity reference. Encoding turns that text into something the browser displays verbatim instead of interpreting. Everything runs locally in your browser, so the text you paste is never uploaded to a server.

How it works

The tool runs entirely in your browser. Paste text into the input, pick Encode or Decode, and the output updates so you can copy it.

Encoding scans your text and replaces characters that are syntactically significant in HTML with named or numeric entities. The core five are:

  • &&amp; (must be encoded first, since every other entity begins with &)
  • <&lt;
  • >&gt;
  • "&quot;
  • '&#39; (or &apos;)

Decoding parses entity references and resolves them back to characters. It understands named entities (&copy;), decimal numeric references (&#169;), and hexadecimal references (&#xA9;), all of which yield the same © character.

Because the conversion is rule-based and local, there's no rate limit, no account, and nothing leaves your machine. That matters when the snippet you're cleaning up contains internal code, tokens, or unreleased copy.

A worked example

Say you want to show readers a literal <a> tag inside an article, including its attributes. If you paste the raw markup into your HTML, the browser will render a clickable link instead of printing the code.

Start with this source text:

<a href="/docs">Read the docs & more</a>

Run Encode and you get:

&lt;a href=&quot;/docs&quot;&gt;Read the docs &amp; more&lt;/a&gt;

Drop that encoded string into your page and the browser displays the tag as text, character for character, including the & in "docs & more". Running Decode on the encoded version returns the original source exactly. This round-trip is the quickest way to confirm a string is safe to embed: encode it, paste it, and verify the page shows the code rather than acting on it.

Common use cases

A few situations where entity conversion is the right move:

  • Displaying code in documentation or tutorials. Any time you want to show HTML, XML, or template syntax as text, encode it so the browser prints the tags instead of executing them.
  • Escaping dynamic or user-supplied content. Comments, search terms, usernames, and form values should be encoded before they're inserted into a page so they can't introduce stray markup.
  • Cleaning up scraped or copied text. Content pulled from another page often arrives already encoded (&amp;amp;, &#39;). Decode it once to recover the real characters.
  • Fixing email and CMS exports. Many editors and newsletter tools store body text with entities baked in; decoding reveals what the reader actually sees.
  • Authoring static HTML by hand. Encode special characters in headings, attribute values, and inline text so the file validates.

In each case the goal is the same: control whether a character is treated as data or as markup.

Tips and gotchas

Encode the ampersand first. If you replace < and > before &, you can corrupt the entities you just created. Correct tooling always handles & before anything else, which is what this tool does.

Double-encoding is a real bug. Encoding an already-encoded string turns &amp; into &amp;amp;, which shows up on the page as the literal text &amp;. If you see entity-looking text rendered to users, you've likely encoded twice. Decode once and check.

Quotes only matter in certain places. Inside an attribute value, an unescaped " ends the attribute early. In plain text content, quotes are harmless. Encoding them everywhere is safe and simple, so the tool does.

Numeric and named entities are interchangeable. &copy;, &#169;, and &#xA9; all decode to ©. If a target system doesn't support named entities, numeric references are the safer choice.

Named vs. numeric entities

HTML offers three ways to reference a character that you'd rather not type literally.

Named entities use a human-readable label between & and ;, like &amp;, &lt;, &nbsp;, or &euro;. They're readable but limited to the set defined by the HTML specification.

Decimal numeric references use the character's Unicode code point in base 10: &#8364; is the euro sign. Hexadecimal references use the same code point in base 16, prefixed with x: &#x20AC; is also the euro sign. Numeric references can express any Unicode character, including ones that have no named entity.

For the five characters that affect parsing (&, <, >, ", '), encoding is about correctness and safety. For everything else, such as accented letters, currency symbols, or emoji, entities are mostly a convenience: modern pages saved as UTF-8 can usually include those characters directly. When in doubt, the numeric form works everywhere.

Tips

  • Always encode `&` before `<` and `>` to avoid mangling the entities you're producing.
  • If users see literal `&amp;` text on a page, you've double-encoded. Decode once and re-check.
  • Encode quotes when the text will sit inside an HTML attribute value, where an unescaped quote ends the attribute.
  • Use numeric references (`&#169;`) instead of named ones when the destination doesn't support the full named-entity set.
  • Round-trip to verify: encode a snippet, paste it into your page, and confirm the code shows as text rather than rendering.
  • Pasting sensitive snippets is fine here since the conversion runs locally and nothing is sent to a server.

How to use HTML Entity Encoder & Decoder

  1. 1Paste your text or HTML.
  2. 2Click Encode to convert characters like < > & " to entities.
  3. 3Or click Decode to turn entities back into characters.
  4. 4Copy the result — all local.

Frequently asked questions

What's the difference between &amp;lt; and just <?

`&lt;` is the entity that displays as a literal `<` on the page, while a raw `<` is read by the browser as the start of a tag. Encode it when you want the character shown as text instead of interpreted as markup.

Which characters actually need to be HTML-encoded?

The five that affect parsing: `&`, `<`, `>`, and the quote characters `"` and `'`. Other characters like accented letters or symbols can usually be left as-is in a UTF-8 document, though entities still work.

Does encoding HTML entities prevent XSS?

Encoding text before inserting it into HTML is a key defense, because it stops attacker-supplied characters from being parsed as tags or attributes. It is not a complete solution on its own; data placed into JavaScript, URLs, or CSS contexts needs encoding appropriate to that context.

Why does my decoded text still show &amp;amp; or &amp;#39;?

The source was encoded more than once. Each decode pass removes one layer, so run the decode again until the literal characters appear.

Are &copy;, &#169;, and &#xA9; the same thing?

Yes. They're the named, decimal, and hexadecimal references for the same character, the copyright sign ©. All three decode identically; numeric forms work in places that don't recognize named entities.

Should I encode quotes inside attribute values?

Yes. An unescaped double quote inside a double-quoted attribute ends the value early and can break the tag. Encoding it as `&quot;` (or `&#34;`) keeps the attribute intact.

Is &apos; safe to use for a single quote?

`&apos;` is valid in HTML5 and XML/XHTML, but older HTML4 contexts don't recognize it. The numeric reference `&#39;` works everywhere, so it's the safer choice when targeting unknown environments.

Is my text uploaded anywhere when I use this tool?

No. Encoding and decoding happen in your browser, so the text you paste stays on your device and isn't sent to any server.

← All toolsRead our guides →