Convert B to KiB

B
0.0009765625KiB

1 B = 0.0009765625 KiB

A kibibyte is 1,024 bytes, so converting bytes to KiB is a division by 1,024 rather than by 1,000. That is the unit behind the "K" in `ls -lh` and `du -h`, neither of which writes the i, and it is why an exact byte count and a tool’s rounded display disagree.

  • Where it runs In your browser. The number you type is never part of a request.
  • Exact by definition 1 B is exactly 0.0009765625 KiB — a definition, not a rounded factor.
  • Answers as you type No button, no wait. The worked answer is already on the page before any script runs.

Byte to Kibibyte in practice

  • 5000000 B is 4883 KiB

    — a photograph from a phone.

  • 1024 B is 1 KiB

    — a kibibyte, which is where the confusion starts.

  • 524300 B is 512 KiB

    — half a mebibyte.

  • 4096 B is 4 KiB

    — one page of memory on most systems.

Byte to Kibibyte at a glance

Every figure here is computed from the same definition the calculator uses, so the table cannot drift away from the answer above it.
BKiB
100.009765625
200.01953125
500.048828125
1000.09765625
5000.48828125
10000.9765625
50004.8828125
100009.765625

Byte and Kibibyte

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.

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.

It takes 1,024 bytes to make a kibibyte

Going this way is a division, and by a whole number: 1,024 of these fit into one kibibyte with nothing left over. The awkwardness is only that the answers come out as fractions — a third of a kibibyte, a twelfth of one — rather than as the round figures the other direction gives you.

Nothing is lost to rounding even so. The division is exact, and if your answer will not sit still as a decimal — 0.0833… and friends — that is the fraction showing through, not an error creeping in.

KiB is the binary one

One KiB is 1,024 of the unit below it; one kB is 1,000. On this page that is the difference between 1024 B and 1000 B — 2.4 % — and the gap grows at every step up the scale, which is why it is a rounding error on a photograph and a visible chunk of a hard disk.

This is the whole of the missing-storage mystery, and on this page it is worth 2.4 %. A drive sold in kB holds exactly what the label says; Windows divides by 1,024 instead of 1,000, keeps the decimal name, and reports 1000 B where the box said 1024. macOS has counted these in the decimal units since 10.6, which is why the same drive can look two sizes on two machines — nothing is missing and nobody is rounding, the same bytes have two names.

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.

The K that means 1,024, and the flag that changes it

GNU coreutils uses upper-case K, M and G for powers of 1,024 and lower-case k for 1,000, which is a convention almost nobody knows and no tool announces. du -h reports binary. du --si reports decimal on the same directory and will differ by 2.4 per cent at the kilo step. df with no options prints 1 KiB blocks; df -h is binary; df -H is decimal.

The practical consequence is that "how big is this directory" has two correct answers from one command, and which one you get depends on a flag somebody typed a week ago in a script. If a number is going into a ticket or a capacity plan, record the flag with it, or convert to bytes first and let the reader pick their own scale.

Why the block is 1,024 bytes and not 1,000

Memory is addressed by lines that are either high or low, so the quantities a machine reaches for naturally are powers of two. Ten address lines reach 1,024 locations, which is close enough to a thousand that the kilo prefix was borrowed, and the borrowing was never undone. That is the historical accident the whole binary-versus-decimal argument descends from.

It is not only historical. Filesystems allocate in blocks that are powers of two, memory pages are 4,096 bytes on ordinary hardware, and disks moved from 512-byte sectors to 4,096-byte ones. Converting bytes to kibibytes is therefore the conversion that lands on real boundaries; converting bytes to decimal kilobytes gives a tidier number that nothing underneath is built to.

A byte is eight bits, and this conversion is not about bits

Every figure on this page counts bytes. Content-Length, file sizes, buffer lengths and disk usage are all byte counts, and a byte has been eight bits since the convention settled — early machines used six, seven or nine, and the eight-bit byte won partly because it holds one character and halves neatly.

Bit rates are the exception that bites. Link speeds, bandwidth caps and encoder settings are quoted in bits per second, so a 100 Mbit/s connection moves at most 12.5 MB per second, and dividing the two figures without noticing gives an answer wrong by a factor of eight. The letter case is the only signal: Mb is megabits, MB is megabytes.

The bytes a file contains and the bytes it occupies

A 900-byte file is 900 bytes long and takes 4,096 bytes of the volume, because storage is handed out in whole blocks. ls -l reports the first number and du reports the second, which is why a directory of small files can consume several times what its contents add up to. du --apparent-size switches du to the byte count and makes the two agree again.

This matters most at the small end, which is exactly where a bytes-to-KiB conversion lives. Ten thousand configuration files of 200 bytes each are 2 MB of content and roughly 40 MiB of disk. If the number you are converting came from a quota tool, it is probably allocated size; if it came from a length header, it is content.

Rounding up, and using it to identify the tool

Coreutils rounds its human-readable sizes up rather than to nearest, so a 1,025-byte file prints as 1.1K even though 1.0 would be nearer. The rule is that the display should never claim less than is there. Other tools round to nearest, and file managers frequently truncate, which is how three programs produce three sizes for one file and all of them look defensible.

You can use this deliberately. Create a file of exactly 1,025 bytes, list it, and read the answer: 1.1K means coreutils-style rounding on a 1,024 base, 1.0K means round-to-nearest, 1.0k or 1.1k means the decimal scale. That takes ten seconds and settles an argument that otherwise runs for an afternoon.

When the byte count is the only figure worth keeping

Some numbers cannot survive a conversion. A Content-Length must be the exact byte count or the response is malformed. A Range header addresses byte offsets. A multipart upload has a minimum part size expressed in bytes. A memory allocation is an integer count of bytes, and rounding it to a friendly unit is how an off-by-a-block bug gets written.

So convert for the human and keep the integer for the machine. The useful discipline is to store bytes everywhere in code and logs, and to convert only at the point of display, labelling the result KiB rather than KB so the next person does not have to work out which thousand you meant.

Sparse files report a size they have never occupied

A sparse file is one whose unwritten regions are recorded as holes rather than stored as zeros, and it breaks the relationship between a byte count and a quantity of disk in the opposite direction from block rounding. A virtual machine image created at 40 GB may occupy a few hundred kibibytes until something writes to it. ls -l reports the full logical length, because that is what the file claims to be; du reports the tiny allocated figure, because that is what exists.

This is worth knowing before converting a byte count, because the two tools are answering different questions and only one of them is the question you have. If the number is going into a capacity plan, the allocated figure is the honest one and it will grow. If the number is going into a transfer estimate, the logical figure is what a naive copy will actually write, and the destination will need all of it unless the copying tool understands holes.

Convert B to KiB: common questions

Does the "K" in `ls -lh` mean 1,000 or 1,024?

It means 1,024 — a kibibyte written without the i. GNU coreutils prints K, M and G for powers of 1,024 and reserves the lower-case k for the decimal scale, which you get with `ls --si`. So `ls -lh` and `ls -lh --si` will show two different numbers for one unchanged file, and neither of them is wrong.

Why does `ls -lh` show 1.1K for a 1,025-byte file?

Because the human-readable output rounds up rather than to the nearest value. 1,025 bytes is 1.0009 KiB, and coreutils prints 1.1K so that the displayed figure never understates what is there. It is a deliberate choice, and it is the quickest way to confirm which tool you are reading.

Why does `du` report more than the byte count of the file?

`du` reports what the file occupies on disk, and a filesystem allocates in whole blocks — usually 4 KiB. A 900-byte file consumes 4,096 bytes of the volume. `du --apparent-size` reports the byte count instead, which is the figure `ls -l` gives you.

Is a byte here eight bits?

Yes. Everything on this page counts bytes of eight bits, which is what `Content-Length`, file sizes and buffer lengths all mean. Network and link rates are quoted in bits per second instead, so a figure in Mbit/s is eight times larger than the same throughput written in MB/s.

When should I keep the number in bytes rather than converting?

Whenever the value has to match something else exactly: a `Content-Length`, a byte offset, a `Range` request, a buffer allocation, a checksum boundary. A rounded KiB figure is a display convenience, and converting back from it will not reproduce the original count.

What is the difference between KiB and KB in tool output?

KiB is unambiguous at 1,024 bytes. KB is not: standards bodies define it as 1,000 bytes, Windows uses it for 1,024, and command-line tools mostly avoid it in favour of a bare K. When a number has to be defended, write KiB or write the byte count.

Going the other way: Kibibyte to Byte

One KiB is 1024 B. It is the same relationship read backwards, so an answer from one page put through the other has to come back to where it started.

Where these figures come from

The claims this page makes about data units are checkable, and these are the documents that settle them.

How this page works

The factor is a constant in the page and the arithmetic is four operations, so nothing is sent anywhere and nothing needs to be. The number you type never leaves the browser — there is no request for it to travel in.