What each Data unit is
Byte B
A byte is eight bits, though that was not always fixed — early machines used six, seven or nine. The eight-bit byte won because it holds one character of text and divides neatly in half.
Kilobyte kB
A kilobyte is 1,000 bytes when a standards body defines it and 1,024 when an operating system does. This page uses 1,000; the kibibyte is the unit that means 1,024.
Megabyte MB
A megabyte is a million bytes. Storage manufacturers have always used this decimal meaning, which is why their capacities look larger than what a computer reports.
Gigabyte GB
A gigabyte is a billion bytes in the decimal sense used by drive manufacturers, phone plans and video sizes.
Terabyte TB
A terabyte is a trillion bytes. A drive sold as 1 TB is exactly that — the space that seems to go missing is a unit disagreement, not a defect.
Kibibyte KiB
A kibibyte is exactly 1,024 bytes. The name was coined in 1998 precisely so that "kilobyte" could go back to meaning 1,000, though the habit never fully took.
Mebibyte MiB
A mebibyte is 1,024 kibibytes, or 1,048,576 bytes. Linux tools and memory sizes generally mean this even when they print "MB".
Gibibyte GiB
A gibibyte is 1,073,741,824 bytes — about 7% more than a gigabyte. Windows measures in gibibytes and labels them GB, which is the whole of the missing-space mystery.
Tebibyte TiB
A tebibyte is 1,024 gibibytes. The gap against the terabyte has grown with each step: 2.4% at kilo, 4.9% at mega, 7.4% at giga, 10% at tera.
Notes on the common Data conversions
gb to mb
The thousand this page uses, and who else uses it
This page divides by a thousand because that is what the prefix means. Kilo, mega and giga are SI prefixes for 10³, 10⁶ and 10⁹, and they carry those values on every other quantity they are attached to — a kilometre, a megawatt, a gigahertz. Applied to bytes they give 1,000, 1,000,000 and 1,000,000,000, which is the meaning used by drive manufacturers, by every network standard, by mobile data plans and by the file sizes services quote in their own documentation.
The rival system is real and this page is not it. Powers of 1,024 give the kibibyte, mebibyte and gibibyte — KiB, MiB and GiB — and those are what most desktop operating systems count in, whatever letters they print. The two systems answer different questions and both are correct inside their own conventions; the mistake is reading a number from one and a limit from the other without noticing which is which.
bytes to gb
Where the byte count on your screen came from
Exact byte counts come from the tools that refuse to round: stat and ls -l, a Content-Length header, the size column in an object store, a database asked how large a table is, a log line recording an upload. None of them are trying to be readable. They report the number the filesystem actually holds, which is why the figure runs to ten or eleven digits and why nobody can read it at a glance.
That exactness is the reason to start from it rather than from a friendlier figure. The byte count is the file; every other rendering of the size is a rounded translation of this number, and the translations disagree with each other. Converting from bytes puts you upstream of the disagreement, and it means the answer you get is a decision you made rather than one a file manager made for you.
bytes to gib
A raw byte count is the one figure two systems cannot disagree about
Software emits sizes in bytes on purpose. A byte count has no prefix to interpret, no rounding to unwind and no locale in it, so a metrics scrape, a log line and an API response can all be compared without anybody agreeing on what a G means first. That property is exactly what makes the numbers unreadable: 17,179,869,184 conveys nothing until it has been divided by something.
The division to use is 1,073,741,824 when the surrounding system is binary, which for memory, page cache, file system usage and most operating-system counters it is. That figure is 16 GiB exactly. Reaching for a billion instead gives 17.18 and hides the fact that the number was a clean power of two, which is often the most informative thing about it.
bytes to kb
The scale where every byte is still countable
Below about a megabyte the raw byte count is not yet unreadable, which changes what the conversion is for. Nobody converts 27,504 bytes to kilobytes because they cannot understand the original; they do it because everything they want to compare it against — an asset budget, a limit on a form, another file someone quoted at 30 kB — is written in kilobytes. The conversion is a translation into the unit the conversation is happening in.
That also means precision is cheap here. One decimal place carries a hundred bytes and two carry ten, so 27.5 kB and 27.50 kB are both honest and the second is not padding. Higher up the ladder the extra digits stop meaning anything, but at this scale a tenth of a kilobyte is a real quantity somebody could remove from a file.
bytes to kib
One file, two numbers: `ls -l` against `ls -lh`
Run `ls -l` and you get an exact count of bytes, which is what the filesystem records and what every API that reports a size returns. Run `ls -lh` on the same file and you get something like 24K. Nothing about the file changed between the two commands — the second divided by 1,024, rounded, and appended a letter that does not say which scale it used.
That is the reason to convert bytes to KiB by hand at all. The exact number is the one that has to match a header, a hash boundary or a quota; the rounded one is the number a colleague quotes back at you from a terminal. Being able to move between them without guessing which base the tool used is the whole skill here.
bytes to mb
Why a machine hands you bytes in the first place
Bytes are what every layer underneath the display actually counts. A directory listing without formatting flags, the st_size field of a stat call, a Content-Length header, the size attribute in an object-storage listing and the length field in a log line are all integers of bytes, because a byte is the one unit in this area with no dialect: it is the same quantity in every system, on every platform, under every convention.
That is precisely why interfaces emit it. The moment a size is turned into megabytes it has acquired both a divisor and a rounding, and neither travels with the number. An API returning 5242880 has told you something unambiguous; an API returning "5.24 MB" has told you something that needs a footnote. Converting is your job, at the end, and knowing that keeps the exact figure available for as long as it is useful.