HTML

HTML Encode

Details

How to use HTML Encode

What the tool does, how to run it, and what to expect from the result.

How to escape text as HTML entities

HTML escaping stops text from being read as markup. Without it, a user who types a less-than sign followed by a tag name can inject elements and scripts into your page, and a user whose name contains an ampersand can quietly break your layout.

The transformation is small on purpose: five characters, replaced in the right order. It runs locally in your browser, and the output is safe to paste into HTML element content or into a quoted attribute value.

  • Paste the raw text that will be inserted into your HTML.
  • Copy the escaped output, in which ampersands, angle brackets, and quotes have been replaced with entities.
  • Place it into element content or into a quoted attribute value.
  • Do not place it unescaped into a script tag, a style block, or an href, because a different escaping rule applies in each of those contexts.
  • In application code, prefer your framework's built-in escaping over pasting escaped strings, so that new content is protected automatically.
Tips

Getting a better result out of HTML Encode

Specific settings and thresholds, not general advice.

  • Exactly five characters are escaped: ampersand, less-than, greater-than, double quote, and apostrophe. That is the correct set for HTML text and for attribute values, and it is deliberately small, because escaping more than necessary produces output that is hard to read and no safer.
  • The ampersand must be escaped first, or you double-escape everything else. This tool handles the ordering, but it is worth knowing why: if you convert the less-than sign to < and then escape ampersands, you end up with < and the browser displays the literal text rather than the character.
  • Escaping is context-specific and this covers only one context. HTML escaping does not make a value safe inside a script block, inside a style block, or inside an href attribute, where a javascript: URL is still a javascript: URL no matter how the quotes are escaped.
  • Accented characters, CJK, and emoji are left as literal characters rather than converted to numeric entities. That is correct for any modern page served as UTF-8, and converting them would only make the file bigger.
  • If you are escaping in application code, use your framework's escaping rather than doing it by hand. React, Vue, and every server template engine escape by default, and the vulnerabilities appear precisely where someone opted out with dangerouslySetInnerHTML or the equivalent.
Limits

What HTML Encode does not do

The honest boundary, so you do not lose time finding it yourself.

  • It is not an XSS sanitiser. It escapes five characters for one context and does nothing about javascript: URLs, event handler attributes, or content destined for a script tag.
  • It does not convert non-ASCII characters to entities, so accents and emoji pass through as themselves.
  • It does not strip or validate HTML. If you need to allow some tags and remove others, that is sanitisation, and it needs a real parser and an allowlist.
  • It escapes the whole input uniformly, so it cannot escape a value that is meant to sit inside HTML you want left intact.
Reference

Terms used on this page

Short, plain-language definitions for the formats and settings above.

At a glance

Who HTML Encode is for

A quick way to understand who this helps, what it solves, and where it connects next.

Best fit

Developers, engineers, and anyone working with encoded data.

Ideal for

Quick encoding, decoding, and inspection without a backend or install.

FAQ

Common questions

Short answers for the questions people usually have before trying a utility like this.

Is the HTML encoder free?

Yes. It is completely free to use, with no signup, no account, and no paywall.

Do I need to install anything?

No. It runs in any modern browser on desktop or mobile, with nothing to download and nothing to configure.

Does it stay local?

Yes. The text you paste is processed entirely in your browser and never uploaded to a server.

Is HTML encoding enough to prevent XSS?

Only for the specific case of inserting untrusted text into HTML element content or a quoted attribute value. Those are the most common cases, so escaping goes a long way, but it is not a complete defence. A value placed inside a script tag, inside a style rule, inside an event handler attribute, or as the target of an href needs different handling entirely, and escaping the quotes in a javascript: URL does not disarm it. The reliable approach is to never build HTML by string concatenation and to let your framework escape by default.

Why are only five characters escaped?

Because those five are the only ones that can change the meaning of HTML. The less-than and greater-than signs start and end tags, the ampersand starts an entity, and the two quote characters end attribute values. Everything else is inert in HTML content. Escaping additional characters, which some older tools do, adds bytes and hurts readability without adding safety.

Should I escape accented characters and emoji as entities?

No, not on a modern page. Any document served with a UTF-8 charset renders those characters directly, and converting them to numeric entities makes the HTML larger and much harder to read or search. Entity encoding of non-ASCII text is a legacy practice from an era of unreliable encoding declarations. Set the charset correctly and leave the characters alone.

Why must the ampersand be escaped before the other characters?

Because every escape sequence begins with an ampersand. If you escaped the less-than sign to < and then went back and escaped ampersands, you would rewrite the ampersand you had introduced and produce <, which the browser renders as the visible text < rather than as a less-than sign. Order matters, and getting it wrong is the classic double-escaping bug that makes entity codes appear on the page.

Does my text get sent anywhere?

No. The replacement happens in your browser with a single local pass over the string. Nothing is uploaded or stored.

Recommendations

You Might Also Like

Nearby tools from the catalog that fit the same job or workflow.

Cleanor app

Do it all on your device

Cleanor puts these tools in one app: compress and convert images, video, and audio, work with PDFs, and scan text right on your device. Plus free up storage and clear inbox clutter with Email Cleaner. Start with a free trial.

  • iPhone
  • Android
  • Macsoon
  • Windowssoon