HTML Entity Encoder / Decoder
This HTML entity encoder / decoder is a tool that converts text between its plain text and HTML entity representations. HTML entities are special characters that are used in HTML to represent characters that have special meaning or cannot be directly displayed in HTML. For example, the ampersand (&) character is used to introduce HTML entities, so it must be encoded as & in order to be displayed correctly in HTML.
To encode text to HTML entities, the encoder replaces all applicable characters with their corresponding HTML entities. To decode HTML entities, the decoder replaces all HTML entities with their corresponding characters.
HTML entity encoders / decoders are useful for a variety of tasks, such as:
- Preparing text for display in an HTML document
- Showing code examples on a web page, such as
<div>, without the browser treating them as tags - Reading text that arrived encoded, for example from an RSS feed, an API or a database
- Ensuring that text is displayed correctly in different browsers and devices
INText
OUTEncoded HTML
About HTML Entity Encoder / Decoder
An HTML Entity Encoder / Decoder is a tool that helps convert special characters and symbols in HTML documents into their corresponding HTML entities and vice versa. HTML entities are codes or sequences used to represent characters that have special meaning in HTML, such as the less-than sign ("<"), greater-than sign (">"), and ampersand ("&"). These characters are reserved for markup and can't be used directly in HTML content without causing rendering issues.
The two primary operations of an HTML Entity Encoder/Decoder are as follows:
Encoding: When you want to display special characters or symbols in an HTML document, you encode them as HTML entities. For example, you'd encode a less-than sign ("<") as "<" and an ampersand ("&") as "&". This ensures that the characters are displayed correctly in the browser without being interpreted as HTML markup.
Decoding: On the other hand, when you need to interpret HTML entities in a document and display the actual characters or symbols they represent, you use decoding. Decoding converts HTML entities back into their original characters. For example, it converts "<" back to "<" and "&" back to "&".
HTML Entity Encoder / Decoder tools are useful for web developers and content creators to ensure that the content on a web page is displayed correctly and safely. Encoding &, <, > and quotes is also the basic defence against cross-site scripting (XSS) when you put user input into HTML text or quoted attribute values. It is not enough on its own inside <script> blocks, inline event handlers, URLs or CSS, which each need their own escaping, so in real applications use your framework's built-in escaping rather than encoding by hand.
The options
- Only & < > and quotes encodes just the characters HTML needs. Everything else stays readable, which is all a UTF-8 page needs.
- Also non-ASCII characters encodes accented letters, symbols and emoji too, for files that must stay plain ASCII, such as some emails and older systems.
- Every character encodes letters and digits as well. The text looks the same in a browser but is unreadable in the source, which is sometimes used to hide email addresses from simple spam bots.
- Named, decimal or hex picks the form: named entities such as
éare easiest to read, and the HTML 4 names used here work everywhere. Characters without a name always use a number.
The decoder understands all 2,231 named references in HTML5, decimal and hex codes, and the older names that browsers accept without a semicolon, such as ©. It follows the same rules as a browser, so the result matches what a web page would show.