Skip to content
Test versionSearch

Developer tools

One-pass HTML entity subset codec

Escape five HTML punctuation characters or all code points numerically. Decode a declared entity subset once, with the output kept as plain text.

How it worksFAQRelated tools

Content reviewed:

The example values can be changed. Press Calculate to update the result; you can download it as TXT or CSV and collect scenarios in this tab. Nothing is saved or sent automatically.

Input at most 400 UTF-16 units, no control characters or unpaired surrogate. Each output row at most 500 characters; larger expansions refuse. Processing stays in this page; no external request, automatic storage or rendering input as HTML. Decode lower-case amp, lt, gt, quot, apos, nbsp and semicolon-terminated decimal/hex scalar references. Unknown names stay text; no repeated decoding. Invalid scalars/NUL refuse. Not a full HTML parser or a sanitiser.

Decimal results are approximate. Inputs stay in this browser tab.

How it works

Own bounded text transformations: URL contexts, UTF-8 bytes, one-pass entity subset, scalar inspection/composition and basic Greek lookup. Input at most 400 UTF-16 units, no control characters or unpaired surrogate. Each output row at most 500 characters; larger expansions refuse. Processing stays in this page; no external request, automatic storage or rendering input as HTML. Decode lower-case amp, lt, gt, quot, apos, nbsp and semicolon-terminated decimal/hex scalar references. Unknown names stay text; no repeated decoding. Invalid scalars/NUL refuse. Not a full HTML parser or a sanitiser.

Worked example

With these example values the calculator gives the result below. You can change any value in the form above.

Inputs

Operation
Escape five punctuation characters
Text or entity references
A & ä

Result

Result text
A & ä
Code point count
9
UTF-16 code units
9
UTF-8 bytes
10

Frequently asked questions

How do I escape HTML special characters?

Choose the option that escapes five HTML punctuation characters, or the option that escapes all code points numerically, and calculate. The worked example encodes the text A & ä with the five-character escape.

Which HTML entities can the one-pass codec decode?

It decodes lower-case amp, lt, gt, quot, apos and nbsp, plus semicolon-terminated decimal and hexadecimal scalar references. Unknown entity names stay as plain text.

Why does the HTML entity codec decode only once?

The codec decodes a declared entity subset in a single pass and keeps the output as plain text. There is no repeated decoding, so an encoded entity inside the result is not expanded again.

How long can the input to the HTML entity codec be?

Input is limited to 400 UTF-16 units without control characters or unpaired surrogates. Each output row may hold at most 500 characters, and larger expansions are refused.

What happens with invalid numeric character references?

Invalid scalar values and NUL references are refused rather than converted.

Can the HTML entity codec sanitise untrusted HTML?

No. It is not a full HTML parser or a sanitiser, and it never renders the input as HTML. Processing stays in the page with no external request or automatic storage.