HTML Encoder/Decoder
Convert special characters to HTML entities and back
HTML Entities Reference
Examples
Click an example to load it
<div class="container">Hello & welcome!</div>
const name = "John"; // Comment with "quotes"
<script>alert("XSS")</script>Copyright © 2024 | Price: €50 | "Quoted" & 'single'
<a href="page.html?a=1&b=2">Click & go</a>
Examples
Encode a tag and attribute quotes
<div class="x"><div class="x">Angle brackets and double quotes are all included in the encoder's named-entity map.
Encode symbols and an ampersand
Copyright © 2024 & price €50Copyright © 2024 & price €50The built-in map includes copyright, ampersand, and euro entities while ordinary text and digits remain unchanged.
Decode mixed named entities
<p>5 < 10 && © 2024</p><p>5 < 10 && © 2024</p>Every recognized named reference is replaced, including repeated ampersand entities.
About this tool
HTML Encoder/Decoder uses a built-in character map rather than an external entity library. Encode mode replaces ampersands, angle brackets, both quote characters, selected Latin-1 symbols, punctuation, arrows, and other listed symbols with named HTML entities. Because ampersand is encoded too, existing entity text is encoded again.
Decode mode reverses the same named entities and also accepts semicolon-terminated decimal and hexadecimal numeric character references. Unknown or differently cased named entities are left unchanged because matching is case-insensitive but the reverse-map lookup uses the exact entity spelling.
Conversion updates as the input or mode changes. The result can be copied, and Swap moves the current output into the input while switching between encode and decode. Encode mode also renders the encoded result as a preview, and built-in examples cover tags, scripts, special characters, attributes, math symbols, and arrows.
How to use
Choose Encode or Decode
Use Encode to turn supported characters into named entities, or Decode to turn supported named and numeric references back into text.
Paste the input
Enter plain text in Encode mode or entity text in Decode mode. The output refreshes immediately.
Inspect the exact conversion
Check quotes, ampersands, unsupported entities, and the encode preview. Use Swap to feed the result back into the opposite operation for a round trip.
Copy the result
Copy the complete output after confirming that HTML entity encoding is the correct escaping method for the destination context.
Use cases
Displaying HTML source as text
Encode angle brackets and ampersands so an HTML snippet can be shown instead of interpreted as markup.
Preparing quoted attribute values
Encode the supported quote and markup characters in a value before placing it in an HTML attribute, while still applying context-specific validation.
Reading entity-heavy content
Decode supported named or numeric references copied from HTML into a readable plain-text representation.
Checking entity round trips
Use Swap to encode and then decode a sample while verifying how the tool handles its supported character map.
Common mistakes
Mistake:Using HTML entity encoding for a JavaScript, CSS, or URL context.
Fix:Escape for the actual output context. HTML body text, HTML attributes, JavaScript strings, CSS values, and URLs have different encoding rules.
Mistake:Encoding text that already contains entities and unintentionally producing &amp;.
Fix:Decode or otherwise normalize known entity text before encoding it again, and avoid repeatedly passing an already encoded result through Encode mode.
Mistake:Leaving quotes unencoded inside an HTML attribute.
Fix:This encoder maps both double quotes to " and single quotes to '. Keep the entity that matches the attribute delimiter and validate the complete attribute context.
Mistake:Assuming every HTML named entity or every capitalization variant will decode.
Fix:Decode mode only reverses names in the built-in map, plus decimal and hexadecimal numeric references. Unknown or differently cased names can remain unchanged, so inspect the output.
Frequently asked questions
Related guides
References & standards
Related tools
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
C# to VB.NET Converter
Convert a subset of C# — classes, methods, variables, loops — into VB.NET
CSV Data Viewer
Paste CSV and browse rows in a sortable table with delimiter detection
CSV to Chart
Paste or upload CSV data and generate bar, line, pie, or doughnut charts. Export as PNG.
CSV to JSON Converter
Paste CSV data and convert it to pretty-printed JSON instantly — supports custom delimiters, header row toggling, and value trimming.
CSV to Markdown Converter
Convert CSV to a Markdown table and Markdown tables back to CSV