HTML Entity Encoder
Paste text to encode its special characters as HTML entities.
Result
How it is calculated
The tool escapes the HTML special characters as UTF-8 text, both quote types included. It replaces exactly five characters: & for ampersand, < for less-than, > for greater-than, " for double quote and ' for single quote. Every other character, including letters with accents, symbols such as © and emoji, passes through unchanged because UTF-8 pages can show them directly. Empty text gives no result. The input is not already-encoded aware: an existing entity like &lt; has its ampersand encoded again, so encode only raw text once.
Worked example
Input: <b>A & B</b>, which is raw text containing a pair of tags and an ampersand. The tool replaces each reserved character and returns <b>A & B</b>. Pasted into a page, it displays as the original text instead of being read as bold markup. Note that the letters, spaces and slash are untouched; only the angle brackets and the ampersand changed.
Common mistakes
- Encoding the same text twice. The ampersands of the first pass are encoded again, so the page shows
&lt;instead of<characters. - Expecting accented letters or symbols to become entities. Only the five reserved characters change, so non-ASCII text stays as is and your page must be served as UTF-8.
- Relying on encoding for places it does not protect, such as inside a script block, a URL or a CSS value, which need their own escaping.
- Encoding a whole HTML fragment you want to render as markup; the tags will appear as visible text.
- Forgetting that apostrophes become
', a numeric entity, rather than a named one.
About this calculator
HTML entities are text codes that represent characters a browser would otherwise interpret as markup — an unescaped angle bracket or ampersand in page content can break the HTML parser or open the door to cross-site scripting (XSS). Encoding replaces each reserved character (ampersand, less-than, greater-than, and quote marks) with its named or numeric entity so the browser renders it literally instead of acting on it.
Web developers use this kind of encoder whenever user-supplied or dynamic text (comments, form input, code snippets shown on a page) needs to be inserted into HTML safely, and it's a standard step in templating engines and CMS platforms that don't auto-escape output.
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)
This is the tool to reach for when you want to show code on a page: encode the snippet, then place it inside a pre and code block and it displays literally instead of being parsed. Because both quote types are encoded, the output is also safe inside a quoted attribute value. It does not protect text placed in scripts, URLs or style rules. Is there a named entity such as the copyright sign you would like to get instead?