HTML Entity Encoder / Decoder
Encode and decode HTML entities (<, >, &, ", ') and numeric character references locally in your browser without XSS risk.
About this tool
Encoding maps &, <, >, ", and ' to named (<) or numeric (<) entities in a single regex pass. Decoding resolves common named entities plus decimal (&#N;) and hexadecimal (&#xH;) character references via String.fromCodePoint. Embed code examples inside HTML <pre> blocks cleanly.
How to use the entity encoder
- Paste HTML or plain text into the input box.
- Choose Encode to turn special characters into entities, or Decode to turn entities back into characters.
- Tick Numeric (&#60;) if you need numbers instead of names, for systems that reject named entities.
- Copy the output, or use Swap to continue with the output as the new input.
Why HTML entities exist
Some characters have a special meaning in HTML. The less-than sign opens a tag, the ampersand starts an entity and quotation marks end attribute values. When you want these characters to appear as text, they must be written as entities such as < for less-than, & for ampersand and " for a quotation mark. Without them, a browser may read part of your text as markup.
Entities also cover characters that are hard to type, such as a non-breaking space or a right arrow, which can be written as or →.
A worked example
Encoding the sample markup turns every angle bracket into < and >, and every ampersand into &, so the code shows on the page instead of running. Decoding the same output returns the original markup exactly. The sample also includes a script with less-than and greater-than signs, which is a common cause of broken pages when it is pasted into a text field unencoded.
- Encode a code snippet before pasting it into a blog post or a help article.
- Decode a string copied from a web page source to read the real characters.
Who uses an HTML entity encoder
- Web developers showing code samples on a page without it running.
- Content editors pasting text from a word processor into a web form.
- Email designers checking that special characters display correctly.
- Support staff reading escaped text in logs and error messages.
- Students learning how a browser reads markup.
Tips and common mistakes
- Encode the ampersand first when you encode by hand. Otherwise < becomes &lt;, which shows the entity text instead of the character.
- Decode carefully. Decoding markup you do not trust can turn text into live code if you paste it back into a page.
- Named entities such as → need an HTML parser that knows them. The numeric option is the safer choice for old systems.
- Attribute values need quotation marks escaped as " as well as ampersands.
- Your text stays in the browser. Nothing is sent to our server.
Frequently asked questions
Related browser tools
Base64 Encoder / Decoder
Encode and decode Base64 strings with full UTF-8 and URL-safe (Base64URL) support locally in your browser with zero uploads.
CSV to JSON Converter
Convert CSV, TSV, and semicolon-delimited tables into clean JSON arrays locally in your browser with quoted-comma support and zero uploads.
Hash Generator
Compute SHA-1, SHA-256, SHA-384, and SHA-512 cryptographic digests simultaneously locally in your browser using Web Crypto with zero uploads.