Run-length text codec

Encode repeated Unicode code points as character-count JSON pairs or decode them back to text.

The example value has been entered. Check it immediately or change the value.

Input is processed in the browser. Refreshing returns a sample value.

Result

Instructions and example

No. Only consecutive characters form a run, allowing original order to be restored. Counts must be positive integers.

AAAABBBCCDAA becomes JSON pairs for A 4, B 3, C 2, D 1 and A 2. The final A run is not merged with the initial run.

Units are code points, not visual grapheme clusters. Decoding is limited to 100,000 code points and compression is not guaranteed.

Frequently asked questions

Are separated occurrences of a character merged?

No. Only consecutive characters form a run, allowing original order to be restored. Counts must be positive integers.

How are emoji and combining characters grouped?

Units are code points, not visual grapheme clusters. Decoding is limited to 100,000 code points and compression is not guaranteed.

Calculation criteria and reference materials

Verification of calculation criteria: · Calculation·verification principles · Report errors