
HTML Entity Encoder / Decoder API
Development
Escape text for HTML or decode named, decimal and hex entities as you type, with options for just the unsafe characters or all non-ASCII, and a searchable entity table.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
1 endpoint available
Overview
Encode text as HTML entities, decode entities back to plain text, or search the table of named entities.
Operations
- encode: escape text for HTML.
scope"unsafe" (default) escapes only & < > " and '. "non-ascii" also escapes every character above ASCII.styleis "named" (default, like é), "decimal" (é) or "hex" (é). In named style, characters with no name in the table use a decimal reference, and the apostrophe is always '. - decode: turn entities back into characters. Decimal and hex references work for any character. Named entities work for the names in the entity table, which covers the HTML 4 set plus '. Other names, and names without the closing semicolon, are left as written. The web page decodes with the browser's parser, which knows every HTML5 name, so it recognises more names than the API does.
- lookup: search the entity table.
querymatches a name (with or without the & and ;), part of a description, the character itself, or its decimal or hex code point.grouplimits results to one group.
Notes
textis limited to 100,000 characters.- Encoding is for HTML text and attribute values. It does not make text safe inside script or style blocks, or in URLs.
referencesin an encode response counts the entities in the output.- Groups: Reserved, Spaces and invisible, Punctuation, Currency, Symbols, Maths, Arrows, Greek, Latin letters.
Endpoints
POST
https://opentools.ca/api/v1/tools/html-entity-encoderEncode text to HTML entities, decode entities, or look up entities
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| operation | string Enum: encode, decode, lookup | Required | The operation to perform |
| text | string | Optional | Text to encode or decode, 1-100,000 characters. Required for "encode" and "decode". |
| scope | string Enum: unsafe, non-ascii | Optional | What to escape when encodingDefault: unsafe |
| style | string Enum: named, decimal, hex | Optional | Entity style when encodingDefault: named |
| query | string | Optional | Search term for "lookup", up to 100 characters. Empty matches every entity. |
| group | string | Optional | Limit "lookup" to one group, for example "Currency" or "Arrows" |
| limit | number | Optional | Maximum entities returned by "lookup", 1-300Default: 50 |
Response Example
{
"success": true,
"operation": "encode",
"scope": "non-ascii",
"style": "named",
"output": "café <b>5 €</b>",
"references": 6
}Error Codes
400
Bad Request - Missing or oversized input, or an invalid operation, scope, style or group401
Unauthorized - Invalid or missing API key403
Forbidden - API key is inactive or expired, or the request IP is not allowed429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
# Encode
curl -X POST https://opentools.ca/api/v1/tools/html-entity-encoder \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"operation": "encode", "text": "café <b>5 €</b>", "scope": "non-ascii"}'
# Decode
curl -X POST https://opentools.ca/api/v1/tools/html-entity-encoder \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"operation": "decode", "text": "café <b>"}'
# Look up an entity
curl -X POST https://opentools.ca/api/v1/tools/html-entity-encoder \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"operation": "lookup", "query": "euro"}'Rather use it in your browser? Open the HTML Entity Encoder / Decoder