HTML Entity Encoder & Decoder
Escape or unescape special characters into HTML entities (&, <, >).
Client-Side Execution & Privacy Guarantee
This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.
HTML entity encoding replaces characters that have special meaning in markup with named or numeric entities. This prevents the browser from interpreting them as tags or attributes when the text is later inserted into a page.
The encoder turns less-than into its entity, greater-than into its entity, ampersand into its entity, and quotes into their entity forms. The decoder reverses the process, expanding both named and numeric entities back to the original characters.
Named versus numeric entities
Common characters have named entities such as amp, lt, gt, quot, and apos. Numeric entities use the character code point.
The encoder prefers named entities for the five characters that must be escaped in HTML text and attribute values. Other characters are left as-is unless you choose a full numeric encoding mode if the interface provides one.
Context matters
Text content between tags requires escaping of less-than, greater-than, and ampersand. Attribute values additionally require escaping of the quote character that delimits the attribute. The tool performs a general escape suitable for both contexts.
Decoding is context-free: any valid entity sequence is expanded regardless of where it appeared. This is useful when you receive HTML-escaped data from an API or a database.
Security considerations
Proper escaping is one layer of defense against cross-site scripting. It does not replace output encoding that is specific to the insertion context, nor does it sanitize HTML that is intentionally allowed.
Always escape untrusted data before placing it into HTML. The tool helps you inspect and produce the escaped form, but the responsibility for correct placement remains with the application.
When to use this tool
- Preparing user input for safe insertion into HTML
- Decoding entities that arrived in an API response
- Inspecting the escaped form of a string that contains markup
- Converting between named and numeric entity styles
- Debugging display issues caused by double-escaped content
How to use the HTML Entity Encoder & Decoder
- Select encode or decode.
- Paste the plain text or the entity-encoded string.
- Click convert.
- Review the output for the expected entities or characters.
- Copy the result into your template or response.
- If the input contains both entities and raw markup, decide whether you need a full HTML parser instead.
- Clear sensitive content from the page when finished.
Worked examples
Escape a tag
<script>
<script>
Both angle brackets are replaced so the string cannot be interpreted as a tag.
Escape mixed special characters
special characters
amp lt gt quot apos
Ampersand, brackets, and quotes receive their standard entities.
Common mistakes and tips
- Escape data at the last possible moment, just before it is written into the HTML. Escaping too early can lead to double-escaping.
- Numeric entities are useful when you need to represent characters that have no named form or when you want to avoid relying on entity name support.
- The decoder expands entities but does not execute or render HTML. It is safe to paste untrusted content.
- Some systems emit double-escaped content. Decode once to recover the single-escaped form.
- Attribute values that use single quotes still need the apostrophe escaped if the value itself contains one.
Frequently asked questions
Which characters are escaped?
By default the tool escapes ampersand, less-than, greater-than, quote, and apostrophe. Other characters remain unchanged.
Does the decoder handle numeric entities?
Yes. Both decimal and hexadecimal forms are expanded.
Will this prevent all XSS?
It prevents XSS when the escaped string is placed in a text or attribute context. It does not protect against other injection vectors or intentional HTML.
Can I encode only part of a string?
The tool processes the entire input. Encode the untrusted portion separately and concatenate it with trusted markup.
What happens with invalid entities on decode?
Unrecognized sequences are left unchanged so that partial or malformed input does not disappear.