Compression: making files smaller

Photos, songs and videos would fill your phone in days without compression. Compression shrinks files so they take less storage and travel faster across the internet.

Practise this lesson free (7 questions)

Why compress?

Compression makes a file smaller.
Smaller files take up less storage space, upload and download faster, and use less of your mobile data.
Streaming video would be almost impossible without it.

Lossless and lossy

A program file must use lossless compression: losing even one bit could stop it working.
TypeHow it worksUsed forExamples
Losslessno data is lost: the original can be rebuilt exactlytext, program code, spreadsheets, images that need exact detailZIP, PNG
Lossysome data is removed for good, usually detail people are unlikely to noticephotos, music, videoJPEG, MP3

Run-length encoding (RLE)

Run-length encoding is a simple lossless method. It replaces a run of the same value with a count and the value.
A row of pixels: WWWWBBBWWW (W = white, B = black)
becomes 4W3B3W: 10 characters shrink to 6.
RLE works well when there are long runs, such as simple images with large areas of one colour. With no repeats it can make the data bigger: ABCD becomes 1A1B1C1D.
Worked example

Compress BBBBBBWWBBBBBBBB with run-length encoding. How many characters are saved?

  1. Count the runs: 6 Bs, 2 Ws, 8 Bs.
  2. Write each as count then value: 6B2W8B.
  3. Original: 16 characters. Encoded: 6 characters.

Answer: 6B2W8B, saving 10 characters

Key idea

Compression makes files smaller. Lossless compression (ZIP, PNG, RLE) keeps every bit so the original can be rebuilt; lossy compression (JPEG, MP3) removes detail for good to make files much smaller.

Key words
AND
A Boolean operator that gives True (1) only when both inputs are True.
Internet
A worldwide network of networks. It is the hardware: cables, routers and connected computers.
Bit
A binary digit: a single 0 or 1. The smallest unit of data.

All KS3 Computing key terms and definitions →

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. Compress BBBBWWWBBB with run-length encoding.

    Show the answer

    Answer: 4B3W3B

    Count each run: 4B3W3B.

  2. Decompress 3W2B3W to get the original pixels.

    Show the answer

    Answer: WWWBBWWW

    3 Ws, 2 Bs, 3 Ws: WWWBBWWW.

Check you have got it

Answer 7 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.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

Related lessons