HTML Entity Encoder / Decoder
Convert characters that have special meaning in HTML into entities, or decode entities back into readable text.
Without escaping, a stray angle bracket or ampersand in your content can break the page structure — or open a security hole.
Common HTML entities reference
This tool runs entirely in your browser
This tool runs entirely in your browser. The data you paste is processed on your device and never sent to Filorra.
That is not a small detail for developer tools. API responses, tokens, config files, and log excerpts routinely contain credentials and customer data, and pasting them into a server-side tool means disclosing them to a third party.
How to use HTML Entity Encoder / Decoder
Paste your text or HTML
Raw text to escape, or entity-encoded text to decode.
Encode or decode
Special characters are converted in either direction.
Copy the output
Processed locally and never transmitted.
The five characters that matter
Most escaping needs come down to a small set, and knowing which and why makes the rest straightforward.
`<` and `>` delimit tags, so unescaped text containing them can be parsed as markup rather than content. `&` begins an entity, so a literal ampersand must become `&` or the parser may consume what follows as an entity reference.
Inside attribute values, the double quote and the apostrophe both terminate the value. An unescaped quote in an attribute lets content break out of the attribute and into the tag itself, which is the mechanism behind a large class of injection bugs.
Everything else — accents, symbols, emoji — needs no escaping in a UTF-8 document. Writing `é` instead of `é` is a legacy habit from before reliable Unicode support and just makes the source harder to read.
Escaping is context-dependent, and this is where XSS comes from
It is tempting to treat HTML escaping as a general-purpose sanitiser. It is not, and the assumption is a reliable source of vulnerabilities.
HTML entity escaping is correct for text placed in HTML body content. It is not sufficient for other contexts. Inside a `<script>` block you need JavaScript string escaping, and entity escaping does nothing useful. Inside a `style` attribute you need CSS escaping. In a URL attribute such as `href` or `src` you need URL encoding — and you must also reject dangerous schemes, because `javascript:` in an `href` executes regardless of how well the rest was escaped.
The dependable approach is to let your templating framework escape on output, in the context where the value is used. React, Vue, and Angular do this automatically. Escaping manually on input and storing the escaped form is fragile: it double-escapes on re-display, corrupts the data for non-HTML consumers, and still gets the context wrong.
Where stray entities come from
Seeing literal `&amp;` or `<p>` rendered on a page is a double-escaping symptom.
It happens when content is escaped at input, stored escaped, and then escaped again by the template on output. The `&` in the stored `&` gets escaped to `&amp;`, which displays as `&`.
The fix is to store raw text and escape exactly once, at render time. Decoding here is useful for recovering the original content from data that was over-escaped by a previous system.
When to use HTML Entity Encoder / Decoder
- Displaying code samples on a page without them being parsed as markup.
- Escaping user-supplied text before inserting it into a template.
- Recovering readable text from over-escaped database content.
- Debugging why literal entity codes are showing up on a page.
Common problems
- The page shows &amp; instead of an ampersand.
- The content was escaped twice. Store raw text and escape once at render time.
- My code sample is being rendered as HTML.
- Escape the angle brackets, or place the sample inside a pre/code block with the content escaped.
- Is escaping enough to prevent XSS?
- Not on its own. Escaping must match the context — HTML, JavaScript, CSS, or URL. Let your framework escape on output rather than doing it manually.
- Should I escape accented characters?
- No. In a UTF-8 document they are fine as-is. Only the structural characters need escaping.
Frequently asked questions
- Is my content sent to a server?
- No. Encoding and decoding both run in your browser.
- Which characters must be escaped in HTML?
- Less-than, greater-than, and ampersand in body content, plus both quote characters inside attribute values.
- Does escaping prevent XSS?
- Only when it matches the context. HTML escaping does not protect a JavaScript block, a style attribute, or a URL attribute. Framework-level output escaping is the reliable approach.
- Why do I see &amp; on my page?
- Double escaping. The text was escaped before storage and again on output.