Skip to content
100% local

Run-length encoding

Compress repeated characters into count-character pairs, and decode them back.

Input
Output

Run-length encoding

Run-length encoding replaces repeated characters with a count and the character itself: "aaabcc" becomes "3a1b2c" — three a's, one b, two c's. This tool encodes text that way, and decodes it straight back, entirely in your browser. It is the same principle behind fax compression, BMP's RLE variant and simple game-asset formats: repetitive data shrinks a lot, and text with no repetition barely changes size at all.

Two format options control how each run is written: count before the character (3a) or character before the count (a3). Turning on "only compress runs longer than 1" leaves single occurrences bare — "aaabcc" becomes "3ab2c" instead of "3a1b2c" — which reads closer to how RLE is taught, at the cost of needing a separator for text that also contains digits. A separator between runs (a comma, a space, anything you type) removes that ambiguity entirely, and is required reading for byte mode. "Process line by line" keeps runs from crossing line breaks, useful when each line is really its own record.

Byte mode treats the input as hex bytes instead of text characters — paste hex like "00 00 00 ff" (spaces are ignored) and it is grouped and compressed byte by byte, which is how RLE is actually used on binary data such as uncompressed image rows. Decoding mirrors every option: pick the same format, separator and byte-mode setting used to encode, and the original text or hex comes back exactly. The live tally shows input and output length plus the compression ratio, so you can see at a glance whether a given input is a good candidate for run-length encoding at all.

Everything runs locally in your browser — nothing you paste in is uploaded anywhere. Copy the result, download it as a .txt file, or send the output straight back into the input to switch direction and verify the round trip.

FAQ

What does 3a1b2c actually mean?
It means three a's, one b, then two c's — the run-length encoding of "aaabcc". The count always comes with the character it counts, in whichever order the format option picks.
Why does decoding sometimes fail or produce the wrong text?
Decoding assumes the format, separator and byte-mode options match what was used to encode. If the original text contains digit characters and no separator was used, the digits can be misread as part of a count — add a separator to avoid that.
When is run-length encoding actually useful?
On data with long repeated runs — solid-color image rows, padding bytes, repeated log characters — it shrinks output a lot. On typical prose it usually grows the output, since most characters do not repeat.
What is byte mode for?
It treats the input as hex-encoded bytes rather than text, so you can run-length encode binary data (pasted as hex) the way image and fax formats do, byte by byte instead of character by character.
Is my text uploaded anywhere?
No. Encoding and decoding run entirely in your browser — nothing you type or paste ever leaves your device.