HTML Encoder

Convert special characters to HTML entities so they display as text.

  • Runs in your browser
  • Free, no sign-up
Paste text to start

About the HTML Encoder

To show a piece of code, a math expression or any text with < and > on a web page, those characters have to be written as HTML entities. Otherwise the browser reads them as tags. The HTML Encoder converts your text for you: < becomes &lt;, & becomes &amp;, and quotes become &quot; and &#39;.

By default, only the five characters that matter in HTML are encoded, which keeps the result readable. You can also encode every character outside basic ASCII, such as accented letters, symbols and emoji, for systems that cannot handle UTF-8, or encode every character for special cases. Entities can be written as names (&eacute;), decimal numbers (&#233;) or hex numbers (&#xE9;).

Encoding text before you insert it into HTML is also what keeps user input from turning into running scripts. Everything happens in your browser.

How to use it

  1. Paste your text or codePaste the text you want to show on a page, or drop a file onto the box. Sample loads a short HTML snippet with accents, a euro sign and an emoji.
  2. Choose what to encodeSpecial characters encodes & < > " and '. Plus non-ASCII also encodes accents, symbols and emoji. Every character encodes everything except line breaks and tabs.
  3. Pick the entity styleNamed entities are easiest to read. Decimal and hex numbers work for every character, including those without a name.
  4. Keep spaces if neededTurn on "Spaces as &nbsp;" to stop the browser from collapsing runs of spaces or breaking a line between two words.
  5. Copy the resultThe status line counts the encoded characters. Copy the result or download it as an .html file.

Key features

Safe HTML in one step

Encodes the five characters that could be read as markup: & < > " and '.

Three scopes

Only special characters, special plus non-ASCII, or every character.

Three entity styles

Named (&eacute;), decimal (&#233;) or hexadecimal (&#xE9;). Characters without a name fall back to a number.

Emoji and symbols

Characters outside the basic plane, such as 😋, are encoded as one entity, &#128523;, not as two broken halves.

Non-breaking spaces

Optionally turn every space into &nbsp; to keep words together.

Private by design

Nothing is uploaded. Your code and text stay in your browser.

Examples

Showing HTML code on a page

The Sample button loads this line:

<p class="note">Café & crème brûlée cost €4 — "très bon" 😋</p>

With the default settings, 9 characters are encoded:

&lt;p class=&quot;note&quot;&gt;Café &amp; crème brûlée cost €4 — &quot;très bon&quot; 😋&lt;/p&gt;

Put that inside a page and visitors see the original tag as text instead of a styled paragraph. The accents, euro sign, dash and emoji stay as they are, because UTF-8 pages show them fine.

Encoding non-ASCII characters too

With Plus non-ASCII, the same line has 17 characters encoded. The accented letters and symbols look like this in each style:

CharacterNamed, decimal and hex
é&eacute; &#233; &#xE9;
€&euro; &#8364; &#x20AC;
—&mdash; &#8212; &#x2014;
😋&#128523; &#128523; &#x1F60B;

The emoji has no name, so even the Named style uses its number.

Code snippets

  • if (a < b && c > d) becomes if (a &lt; b &amp;&amp; c &gt; d)
  • It's 5 > 3 becomes It&#39;s 5 &gt; 3
  • <script>alert(1)</script> becomes &lt;script&gt;alert(1)&lt;/script&gt;, which a browser shows as text and never runs

Symbols with names

With Plus non-ASCII and Named, © 2026 ™ ½ × → ♥ becomes &copy; 2026 &trade; &frac12; &times; &rarr; &hearts;.

Tips

  • For normal web pages saved as UTF-8, Special characters is all you need. Encoding accents and emoji only makes the source harder to read.
  • Use Plus non-ASCII for HTML emails and for systems that store text in an old character set. Entities then survive any conversion.
  • When you write a tutorial or documentation, encode code samples before you paste them inside <pre> or <code> tags.
  • Turn on "Spaces as &nbsp;" for short pieces such as "10 km" or "Fig. 3", where a line break between the parts would look wrong. Do not use it for whole paragraphs.
  • To reverse the process, paste the encoded text into the HTML Decoder.

Common mistakes and limits

  • Encoding twiceEncoding text that already contains entities turns &amp; into &amp;amp;, so visitors see "&amp;" on the page instead of "&". Encode the original text only once.
  • Encoding HTML you want to renderEncoding is for showing code as text. If you encode markup that should create a heading or a link, it shows up as plain text instead.
  • Relying on encoding inside scripts and URLsHTML entities protect text placed between tags and in quoted attributes. Inside <script> blocks, style blocks or URLs, different escaping rules apply.
  • Using Every character for normal contentIt turns "Hi" into &#72;&#105;. That can hide text from simple scrapers, but it makes pages larger and harder to maintain.
  • Expecting the apostrophe to use a nameThe apostrophe is always written as &#39;, because &apos; is not supported in older HTML versions and some email clients.

Frequently asked questions

What are HTML entities?
Codes that stand for a character in HTML, written as & followed by a name or a number and a semicolon. &lt; stands for <, &eacute; for é and &#128523; for 😋.
Which characters must be encoded in HTML?
The ampersand (&) and the less-than sign (<) always, when they appear in text. Greater-than (>) and quotes (" and ') should be encoded too, especially inside attribute values. Special characters mode encodes all five.
What is the difference between named, decimal and hex entities?
They mean the same character. Named entities like &eacute; are easier to read but exist only for some characters. Decimal (&#233;) and hex (&#xE9;) numbers work for every Unicode character.
Does HTML encoding prevent XSS?
It is the main defense when you put user text between HTML tags or into a quoted attribute: <script> becomes harmless text. Other places, such as JavaScript code or URLs, need their own escaping.
Do I need to encode accented letters and emoji?
Not on pages saved and served as UTF-8, which is the standard today. Encode them only when a system or an email client may not handle UTF-8 correctly.
What does "Spaces as &nbsp;" do?
It replaces every normal space with a non-breaking space. Browsers do not collapse those or break lines at them, so the text keeps its spacing and stays on one line.
Are line breaks encoded?
No. Line breaks and tabs are kept as they are in every mode, so the structure of your text or code is preserved.
Is my text sent anywhere?
No. The encoding runs in your browser, and nothing is uploaded.