ToolMight LogoToolMight

HTML Entity Converter

Encode special characters into named, decimal, or hexadecimal HTML entities, or decode HTML entities back into raw strings online with live preview.

Loading Tool...

Encode text strings into named, decimal, or hexadecimal HTML entities, or decode entity-encoded HTML strings back to raw text. Protect Web applications against XSS vulnerabilities, render reserved characters safely, and manage Unicode symbols client-side.

Learn About This Tool

Understanding HTML Entities & Reserved Character Security

Web browsers use reserved characters like <, >, &, and " to define tag structures and attributes. Displaying raw user input containing these characters directly in HTML causes tag parsing errors or introduces severe Cross-Site Scripting (XSS) security vulnerabilities. HTML entities convert reserved characters into safe character reference codes that browsers render as visible text without executing as HTML code.
<!-- Raw Text Input -->
<script>alert("XSS")</script>

<!-- HTML Entity Encoded Output -->
&lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;
  • Named entities: Short text mnemonics (e.g. `&lt;` for `<`, `&amp;` for `&`)
  • Decimal entities: Base-10 ASCII/Unicode code points (e.g. `&#60;` for `<`)
  • Hexadecimal entities: Base-16 Unicode references (e.g. `&#x3C;` for `<`)
  • Neutralizes malicious script tag injections when echoing dynamic data

Encoding Scope: Special Characters vs Full Character Map

Depending on your application context, you can select between Special Characters mode (which targets the five primary XML/HTML delimiters &, <, >, ", ') and All Characters mode (which converts all non-ASCII Unicode characters). For URL query string parameter encoding, use our URL Encoder / Decoder.
  • Special Characters mode: Ideal for body text and form field escaping
  • All Characters mode: Useful when embedding raw strings in inline script attributes
  • Encodes extended Unicode symbols, emojis, and non-Latin alphabets safely
  • Preserves whitespace layout while converting symbols

Preventing Cross-Site Scripting (XSS) in Dynamic Applications

Cross-Site Scripting (XSS) remains one of the top OWASP web security risks. When dynamic user data is reflected in HTML body text or input values without entity escaping, attackers can inject arbitrary JavaScript. Entity encoding ensures that input like `<img src=x onerror=alert(1)>` renders as plain static text.
  • Escapes HTML delimiters before inserting values into DOM innerHTML
  • Converts quotes to `&quot;` and `&#39;` to prevent attribute breakout
  • Maintains compatibility across HTML5, XHTML, and XML documents
  • Calculates conversion results 100% locally in browser memory

Fast Client-Side Parsing with Zero Server Requests

All entity encoding and decoding operations run locally inside your browser using optimized JavaScript DOM parsing routines. If you need binary string encoding rather than HTML entity references, check out our Base64 Encoder / Decoder.
  • Local execution guarantees confidential input strings are never sent over HTTP
  • Instant reverse decoding for auditing entity-encoded data streams
  • Handles large string blocks up to 5MB smoothly
  • Export or copy converted results with a single click

How to Use HTML Entity Converter

1

Select Operational Mode

Choose `Encode` to convert text to HTML entities, or `Decode` to convert entity strings back to raw text.

2

Choose Entity Format & Scope

Select Named, Decimal, or Hexadecimal output format, and choose Special Characters or All Characters scope.

3

Input Text & Copy Result

Paste your string into the input editor. The converted output updates instantly in the output panel — click `Copy` to grab the result.

Common questions

What is an HTML entity?

An HTML entity is a character reference starting with an ampersand (`&`) and ending with a semicolon (`;`), used to represent reserved characters or non-printable symbols safely in HTML.

Why should I encode special characters in HTML?

Reserved characters like `<` or `>` can confuse HTML parsers and trigger Cross-Site Scripting (XSS) vulnerabilities if injected by users. Encoding them renders them safely as text.

What is the difference between Named and Decimal entities?

Named entities use text names (`&lt;`), while decimal entities use numerical Unicode code points (`&#60;`). Decimal entities are supported universally across all XML and HTML parsers.

How do I decode HTML entity strings?

Select `Decode` mode, paste the string containing entities (such as `&lt;h1&gt;`), and the tool instantly translates them back into standard text (`<h1>`).

Can HTML entity encoding prevent XSS attacks?

Yes. Encoding user input before reflecting it inside HTML body tags or attribute values prevents injected script tags from executing in the user's browser.

Are non-breaking spaces supported?

Yes. The decoder parses `&nbsp;` into standard space characters, along with symbols like `&copy;` (©), `&reg;` (®), and `&trade;` (™).

Does it support emoji character encoding?

Yes. Emojis and high-plane Unicode characters can be encoded into decimal or hexadecimal entities (e.g. `&#x1F600;` for 😀) for safe transport in legacy character encodings.

Why are some characters encoded as decimal instead of named entities?

Not every Unicode character has a named entity shorthand defined in the HTML5 specification. For those without names, the tool uses decimal or hexadecimal references.

What is the difference between Hexadecimal and Decimal entities?

Decimal entities use base-10 code points (`&#38;`), while Hexadecimal entities use base-16 code points (`&#x26;`). Both are parsed identically by modern web browsers.

Is single quote (apostrophe) encoding valid in XML?

Yes. In XML and XHTML, single quotes encode as `&apos;`, whereas in older HTML4 `&#39;` was common. This tool supports both representations safely.

How does HTML entity encoding differ from URL encoding?

HTML entity encoding replaces reserved HTML markup characters (like `<` and `&`), whereas URL percent-encoding replaces characters invalid in web URLs (like spaces `%20` or `/` `%2F`).

Should I encode JSON payloads as HTML entities?

No. Standard JSON payloads use standard string escaping (`\"`). HTML entity encoding is specifically for data inserted into HTML documents or DOM nodes.

Is my input text sent to an external server?

No. All entity conversion runs 100% inside your browser using client-side JavaScript.

Are there keyboard shortcuts?

Press `Ctrl+L` (or `Cmd+L` on Mac) to clear the editor fields instantly.

Related tools