HTML Entity Encoder

Paste text to encode its special characters as HTML entities.

How it is calculated

The tool escapes the HTML special characters as UTF-8 text, both quote types included. It replaces exactly five characters: & for ampersand, < for less-than, > for greater-than, " for double quote and ' for single quote. Every other character, including letters with accents, symbols such as © and emoji, passes through unchanged because UTF-8 pages can show them directly. Empty text gives no result. The input is not already-encoded aware: an existing entity like < has its ampersand encoded again, so encode only raw text once.

Worked example

Input: <b>A &amp; B</b>, which is raw text containing a pair of tags and an ampersand. The tool replaces each reserved character and returns &lt;b&gt;A &amp; B&lt;/b&gt;. Pasted into a page, it displays as the original text instead of being read as bold markup. Note that the letters, spaces and slash are untouched; only the angle brackets and the ampersand changed.

Try this example →

Common mistakes

  • Encoding the same text twice. The ampersands of the first pass are encoded again, so the page shows &amp;lt; instead of &lt; characters.
  • Expecting accented letters or symbols to become entities. Only the five reserved characters change, so non-ASCII text stays as is and your page must be served as UTF-8.
  • Relying on encoding for places it does not protect, such as inside a script block, a URL or a CSS value, which need their own escaping.
  • Encoding a whole HTML fragment you want to render as markup; the tags will appear as visible text.
  • Forgetting that apostrophes become &#039;, a numeric entity, rather than a named one.

About this calculator

HTML entities are text codes that represent characters a browser would otherwise interpret as markup — an unescaped angle bracket or ampersand in page content can break the HTML parser or open the door to cross-site scripting (XSS). Encoding replaces each reserved character (ampersand, less-than, greater-than, and quote marks) with its named or numeric entity so the browser renders it literally instead of acting on it.

Web developers use this kind of encoder whenever user-supplied or dynamic text (comments, form input, code snippets shown on a page) needs to be inserted into HTML safely, and it's a standard step in templating engines and CMS platforms that don't auto-escape output.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    This is the tool to reach for when you want to show code on a page: encode the snippet, then place it inside a pre and code block and it displays literally instead of being parsed. Because both quote types are encoded, the output is also safe inside a quoted attribute value. It does not protect text placed in scripts, URLs or style rules. Is there a named entity such as the copyright sign you would like to get instead?

Popular calculators

All Calculators