If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

File sizes

Computers can store much more data than they could 20 years ago, but storage is still limited. That's why file size matters: perhaps our computer's hard drive can store 10,000 GIFs of cats, but it can only store 10 full-length movies about cats.
File sizes are always measured in bytes. A byte is a sequence of 8 bits (and remember, a bit is the smallest piece of digital information, 0 or 1).
A single byte is enough bits to represent 256 numbers, because 28=256. That also means a byte is big enough to represent a single letter in the ASCII encoding standard.

A small file

If a byte is enough to represent a single letter, then a 5-letter long text file should be 5 bytes, right?
🔍 Try it yourself: Make a file with just the word "Hello" and then view the file metadata to see the total file size.
When I tried it, my computer made a file with a size of 6 bytes. I expected 5 bytes, since I typed 5 letters and the computer only needs 1 byte per letter. As it turns out, my editor added a new line automatically and that also required a single byte of representation.
byte #characterbinary
1H0100 1000
2e0110 0101
3l0110 1100
4l0110 1100
5o0110 1111
6New line0000 1010

Larger files

Files are often much larger than a few bytes. A 400x400 photo of my face is a whopping 22,096 bytes. A 33-second movie of my cat is 4,614,170 bytes.
To make it easier to talk about larger file sizes, we use larger units, starting with the kilobyte. If you're familiar with units like kilometers and kilograms, a kilobyte sounds like 1000 bytes, but it's not—or at least, it's not always.
When the term was first invented, a kilobyte referred to 1024 bytes. Computer scientists wanted to use familiar terms, but computers are based on the binary system, so it made more sense to group bytes into powers of 2 and 1024 is 210. Some computers started using a kilobyte to refer to 1000 bytes—especially hard drive manufacturers, since it made their drives sound bigger. Now we live in a confusing world where 1 kilobyte sometimes equals 1024 bytes and sometimes equals 1000 bytes.
Any given computer will be consistent in its units, so you can compare relative file sizes, even if you're not sure the exact conversion from kilobytes to bytes. In the scheme of things, 1000 is close to 1024, so you'll get a good idea for the size of the file either way.
Once a file size is bigger than 1024 kilobytes (or 1000, depending which computer you ask), we can start using the bigger units like megabytes, gigabytes, terabytes, and petabytes.
UnitBytes (base 10)Bytes (base 2)Example
kilobyteKB1000102410x10 icon
megabyteMB1000210242500 page e-book
gigabyteGB10003102437 minutes of video
terabyteTB1000410244130,000 photos
petabytePB100051024520 million file cabinets
The table above gives examples of how much data you can store for each unit. That column is actually a bit deceiving, because file sizes depend on whether the data is "compressed", and how much they've been compressed. 1 gigabyte could store 1 minute of uncompressed video, or it could store 1 hour of compressed low-resolution video. We'll learn much more about compression soon.
🔍 Search online for more examples of data sizes. What else could you fit in a gigabyte, terabyte, or petabyte? Share any interesting discoveries in the Tips & Thanks below.

🙋🏽🙋🏻‍♀️🙋🏿‍♂️Do you have any questions about this topic? We'd love to answer— just ask in the questions area below!

Want to join the conversation?