HTML Encode / Decode
How do I HTML-encode text?
Result
How it is calculated
In encode mode the tool escapes the HTML special characters as UTF-8 text, quotes of both kinds included. It replaces five characters: & becomes &, < becomes <, > becomes >, a double quote becomes " and a single quote becomes '. Every other character, including letters with accents, is left untouched.
Decode mode reverses this: it first undoes those five replacements and then converts any other named or numeric entity (such as é or ©) to its character. Empty input gives no result.
Worked example
Encode the text Tom & Jerry <3 it. Scanning left to right, the first special character is the ampersand, which becomes &. The less-than sign in <3 becomes <. Letters, digits and spaces stay as they are. The result is Tom & Jerry <3 it.
Common mistakes
- Encoding the same text twice. The ampersand in an existing
&is encoded again and the page then shows the literal text&. - Expecting encoding to make text safe in every context. It protects HTML text and quoted attributes, but not text placed inside JavaScript, CSS or URLs.
- Pasting already-encoded text into decode mode twice, which can turn a deliberate
<into a real tag character. - Assuming accented letters or emoji get entities. They are left as they are, so the page must be served as UTF-8.
About this calculator
This tool converts special characters like <, >, & and quotes into their HTML entity equivalents (<, >, & and so on), or reverses the process to decode entities back into readable text. Without encoding, a character like < in user-supplied text gets interpreted by the browser as the start of an HTML tag instead of being displayed literally, which can break page layout or open the door to script injection.
Web developers use it when embedding raw text — code snippets, user comments, or content pulled from another source — into an HTML page safely, and when debugging why a page is rendering a stray tag instead of the literal character it was supposed to show. It's also used in reverse, to decode entity-laden text copied from a webpage's source back into plain, readable text.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Only five characters are touched when encoding: ampersand, less-than, greater-than, and both kinds of quote. Accented letters and other non-ASCII text stay as typed, so the output is safe for showing code inside a page but is not a full named-entity conversion. Decoding goes further and turns any named or numeric entity back into its character. Encode once only, since running the output through again doubles every ampersand. Which entities do you need beyond these five?