# Html entities encode

`html-entities-encode` · version 1.0.0 · Structured formats · free, no key needed

Escape text for safe insertion into HTML text or quoted attribute values and return the encoded text.

**Use when you need to: encode HTML entities · escape text for HTML · make text safe for HTML attribute.**

## Decide before calling

Read the [versioned contract](/v1/tools/html-entities-encode/versions/1.0.0) and the supported scope below. Reuse `html-entities-encode@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `html-entities-encode@1.0.0` for encode HTML entities. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- encode HTML entities
- escape text for HTML
- make text safe for HTML attribute
- encode ampersands and angle brackets
- escape quoted HTML attribute value
- convert text to HTML references

## Not supported

- sanitize an HTML document
- URL or JavaScript escaping
- choose quote delimiters

## Behavior

- Uses WHATWG HTML Living Standard snapshot 2026-11-05, sections 13.5 and 13.2.5.72–80.
- Pins the named-reference table as whatwg-html-entities-2026-11-05-0155d7c70a78.
- This is not a full HTML parser or a sanitizer for untrusted markup.

## Input

- `text` (string, required): max length 8192
- `context` (one of "text", "attribute", required)

## Output

- `text` (string, required): max length 32768
- `standard_version` (string, required)
- `data_version` (string, required)

## Limits

- max input bytes: 8192
- max output bytes: 32768
- max iterations: 16384

## Example

Request input:

```json
{
  "text": "<A & B>",
  "context": "text"
}
```

Response:

```json
{
  "result": {
    "text": "&lt;A &amp; B&gt;",
    "standard_version": "WHATWG HTML Living Standard snapshot 2026-11-05, sections 13.5 and 13.2.5.72–80",
    "data_version": "whatwg-html-entities-2026-11-05-0155d7c70a78"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "html-entities-encode",
  "version": "1.0.0",
  "input": {
    "text": "<A & B>",
    "context": "text"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/html-entities-encode/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"<A & B>","context":"text"}'
```

The machine-readable contract is at [/v1/tools/html-entities-encode/versions/1.0.0](/v1/tools/html-entities-encode/versions/1.0.0).

### CLI

```sh
node cli.mjs run html-entities-encode 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Html entities decode](/tools/html-entities-decode): Decode WHATWG named and numeric HTML character references and return the resulting Unicode text.
- [Asn1 der encode tree](/tools/asn1-der-encode-tree): Encode a schema-free ASN.1 node list as one canonical DER value.
- [Asn1 der parse](/tools/asn1-der-parse): Parse one ASN.1 DER value into a flat schema-free TLV node list.
- [Asn1 der primitive encode](/tools/asn1-der-primitive-encode): Encode one universal DER primitive from typed fields into lowercase hex.
- [Asn1 der tree render](/tools/asn1-der-tree-render): Render one DER value as an escaped text tree of paths, tags, lengths, and previews.
- [Fixed width records parse](/tools/fixed-width-records-parse): Parse fixed-width records with explicit offsets, widths, alignment, padding, Unicode units, and bounded diagnostics.
