# Text run length encode

`text-run-length-encode` · version 1.0.0 · Text · free, no key needed

Run-length encode Unicode text into canonical count:HEX; records and return the encoded string.

**Use when you need to: run length encode text · compress repeated characters · encode character runs.**

## Decide before calling

Read the [versioned contract](/v1/tools/text-run-length-encode/versions/1.0.0) and the supported scope below. Reuse `text-run-length-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 `text-run-length-encode@1.0.0` for run length encode text. 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

- run length encode text
- compress repeated characters
- encode character runs
- make RLE text
- count consecutive Unicode characters
- convert a string to run length format

## Not supported

- general-purpose compression
- byte-oriented run-length encoding

## Behavior

- Format is repeated count:HEX; records, where count is base-10 without leading zero and HEX is an uppercase Unicode scalar value.
- Runs count Unicode code points; adjacent equal code points form one run.
- The empty string encodes as the empty string.

## Input

- `text` (string, required): max length 4096

## Output

- `encoded` (string, required)
- `standard_version` (constant "Unicode 16.0.0", required)

## Limits

- max input bytes: 4096
- max code points: 4096
- max output bytes: 16384

## Example

Request input:

```json
{
  "text": "AA😀😀😀"
}
```

Response:

```json
{
  "result": {
    "encoded": "2:41;3:1F600;",
    "standard_version": "Unicode 16.0.0"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "text-run-length-encode",
  "version": "1.0.0",
  "input": {
    "text": "AA😀😀😀"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/text-run-length-encode/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"AA😀😀😀"}'
```

The machine-readable contract is at [/v1/tools/text-run-length-encode/versions/1.0.0](/v1/tools/text-run-length-encode/versions/1.0.0).

### CLI

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

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

## Related tools

- [Text run length decode](/tools/text-run-length-decode): Decode canonical count:HEX; run-length text and return the expanded Unicode string.
- [Text wrap width](/tools/text-wrap-width): Hard-wrap text by Unicode code-point width and return the resulting lines.
- [Text slugify](/tools/text-slugify): Create a deterministic ASCII or Unicode slug using an explicit, documented normalization profile.
- [Text paragraphs split](/tools/text-paragraphs-split): Split text into paragraphs separated by blank lines (CommonMark line rules) with code point spans and line numbers.
- [Citation record normalize](/tools/citation-record-normalize): Normalize one CSL 1.0.2 citation record: NFC, whitespace, empty values, DOI wrapper, page dashes, dates; lists changes.
- [Text damerau distance](/tools/text-damerau-distance): Compute bounded optimal-string-alignment distance with adjacent transpositions.
