HTML Entity Encode
Free HTML Entity Encode calculator with clear step-by-step results.
About HTML Entity Encode
Escapes the five characters that carry syntactic meaning in HTML so they render as literal text instead of being parsed as markup. Ampersand must be replaced first, otherwise the ampersands introduced by the other replacements get double-encoded - which is the classic bug in hand-rolled escapers.
Formulas
Mandatory replacements
& becomes &, < becomes <, > becomes >
Attribute-safe replacements
Double quote becomes " and single quote becomes '
Worked example
With the default values below, HTML Entity Encode returns Encoded output of Fish & chips <b>cost</b> "5" today. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Text to encode
- Fish & chips <b>cost</b> "5" today
- Also encode quotes
- Yes
- Encode non-ASCII as numeric references
- No
Results
- Encoded output
- Fish & chips <b>cost</b> "5" today
- Characters replaced
- 7
- Encoded length
- 60 chars
- Length increase
- 76.47% %
Step by step
- 1Values used
- 2Mandatory replacements
- 3Attribute-safe replacements
- 4Encoded output= Fish & chips <b>cost</b> "5" today
- 5Characters replaced= 7
- 6Encoded length= 60 chars
- 7Length increase= 76.47 %
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 2 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Do I always need to escape quotes?
Only inside attribute values, but escaping them everywhere is safer and costs almost nothing. Unescaped quotes in an attribute are a common cross-site scripting vector.
Should I encode non-ASCII characters?
Not if the document is served as UTF-8, which it should be. Numeric references are only useful for legacy pipelines that cannot carry the bytes intact.
Related Calculators
You might also need
- 2FA Setup CheckerAlso in Programming & Software
- Algorithm Complexity CalculatorAlso in Programming & Software
- Antivirus Plan CheckerAlso in Programming & Software
- API PaginationAlso in Programming & Software
- API Payload Size CalculatorAlso in Programming & Software
- API Quota CalculatorAlso in Programming & Software
