跳到主要内容

HTML Entity Encoder Online

Quick Try:

HTML Entity Encoding

This HTML entity encoder online converts special characters to named or numeric entities for safe HTML output. HTML entities are strings that begin with an ampersand (&) and end with a semicolon (;). They are used to display invisible characters and reserved characters (such as HTML tags) safely in a document.

You can find a complete list of named character references in the WHATWG specification.

In frontend development, to prevent XSS attacks, characters like <> are encoded as &lt; and &gt;. In practice, only six characters require encoding: &, <, >, ", ', and `.

Encoding Methods

HTML entities can be represented using either Unicode code points or named character references.

For example, <:

  • Its named character reference is lt, so the entity is &lt;
  • Using '<'.codePointAt(), its Unicode code point is 60, so it can also be written as &#60; (decimal) or &#x3c; (hexadecimal)