Run-Length Encoding Generator
Run-length encoding replaces a run of identical characters with a count and the character. On a long run of the same value it is dramatic; on ordinary prose it makes things bigger, and a tool that hides that is teaching the wrong lesson. This encodes what you type, decodes it straight back to prove the transformation is exact, and tells you honestly whether it shrank anything.
What this generator does
Walks the text collecting maximal runs of identical characters, writes each as a count followed by the character, and then decodes the runs back and compares the result to the original character for character.
How to use this tool
- Type or paste text with some repeated characters.
- Run, and read the encoded form.
- Check whether it actually got shorter — often it will not.
- Try a long run of one character to see the best case.
Understanding the controls
- Text
- Anything you like. Long runs of one character compress well; ordinary prose usually expands, which the result says outright.
Common use cases
- Working through run-length encoding with your own examples
- Showing why a compression method can make data larger
- Producing test input for an RLE implementation
- Teaching lossless compression with a scheme simple enough to check by hand
- Encoding simple repeated patterns for a puzzle or exercise
How this generator works
A run continues while the character stays the same, so runs are maximal by construction — two adjacent runs can never share a character, and that is checked before display. Decoding simply repeats each character its stated number of times, and the result must equal the original exactly. The encoded length is compared against the original, and the verdict is reported either way rather than only when it flatters the method.
Randomness and fairness
Nothing here is random. The same text always encodes identically.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Counts are written as decimal digits inline, so a run of ten or more takes more characters to describe — real implementations use a fixed-width byte instead.
- There is no escaping, so text containing digits decodes ambiguously if you feed the output back in as input.
- Only exact repeats count; a nearly repeating pattern gains nothing.
- This is a teaching implementation, not a compression format — it is not compatible with any standard RLE variant.
Privacy and your data
Encoding and decoding happen entirely in your browser. Nothing you enter is transmitted, stored or included in analytics.
Related generators
- Huffman Code GeneratorBuilds an optimal prefix code for your text, shows every character's bit pattern, and decodes the bits back to prove it works.
- Text Diff GeneratorCompares two texts line by line and shows the smallest set of changes, checked by applying them back to the original.
- Edit Distance CalculatorThe fewest single-character edits that turn one word into another, listed step by step and proved by replaying them.
- Random Binary String GeneratorA string of 0s and 1s of a fixed length — not a converted number.