Run-length encoding
Run-length encoding (RLE) is a simple lossless compression method. It shines when data has long runs of the same value.
How RLE works
RLE stores each run as a count and the value, instead of every item.
AAAABBBCCD becomes 4A3B2C1D.
RLE for images
WWWWWBBBWW (10 pixels) becomes 5W3B2W.
The image can be rebuilt exactly, so RLE is lossless.
When it works well
With lots of changes, such as photos or ordinary text, it can make files bigger: ABCD becomes 1A1B1C1D.
Encode BBBBBBWWWB with RLE.
- 6 Bs, then 3 Ws, then 1 B.
Answer: 6B3W1B
RLE stores each run of repeated data as a count and a value. It is lossless and works well with long runs, but can make data with few repeats bigger.
- Run-length encoding (RLE)
- Lossless compression that stores each run of repeated data as a count and a value.
- Lossless compression
- Makes a file smaller without losing any data, so the original can be rebuilt exactly.
- Compression
- Making a file smaller, to save storage space and transmission time.
- Sequence
- Instructions carried out one after another in order.
All GCSE and International GCSE Computer Science key terms and definitions โ
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
Encode AAABBBBBCD using run-length encoding (count then letter, for example 3A).
Show the answer
Answer: 3A5B1C1D
Count each run: 3A 5B 1C 1D. So 3A5B1C1D.
Encode the pixel row BBBBBWWWWWWW using RLE.
Show the answer
Answer: 5B7W
Count each run: 5B 7W. So 5B7W.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.