curatedapi

Data size converter

Convert between bits, bytes and their decimal (kB, MB) and binary (KiB, MiB) multiples.

The amount to convert.
Unit of the value. Options: bit: bit; B: byte; kB: kilobyte; MB: megabyte; GB: gigabyte; TB: terabyte; PB: petabyte; EB: exabyte; ZB: zettabyte; KiB: kibibyte; MiB: mebibyte; GiB: gibibyte; TiB: tebibyte; PiB: pebibyte; EiB: exbibyte; ZiB: zebibyte; kbit: kilobit; Mbit: megabit; Gbit: gigabit; Tbit: terabit; Kibit: kibibit; Mibit: mebibit; Gibit: gibibit
Unit to convert to. Omit to convert to every unit. Options: bit: bit; B: byte; kB: kilobyte; MB: megabyte; GB: gigabyte; TB: terabyte; PB: petabyte; EB: exabyte; ZB: zettabyte; KiB: kibibyte; MiB: mebibyte; GiB: gibibyte; TiB: tebibyte; PiB: pebibyte; EiB: exbibyte; ZiB: zebibyte; kbit: kilobit; Mbit: megabit; Gbit: gigabit; Tbit: terabit; Kibit: kibibit; Mibit: mebibit; Gibit: gibibit
More options: rounding and decimals
Precision and rounding
Rounding mode applied once to each result. Default half_even.
Round results to this many digits after the decimal point.
Round results to this many significant digits.

Examples

Result: One GiB in bytes

Result
The converted value.
1073741824 exact
Factor
How many to_unit make one from_unit (multiply by this to convert).
1073741824 exact

Rounding: Half even, 15 significant digits. Calculator units/data-size@1.

How it is calculated

result = value × factor(from_unit) ÷ factor(to_unit), factors in bits

Convert between bits, bytes and their decimal (kB, MB) and binary (KiB, MiB) multiples. Conversion factors are exact values from the official unit definitions, so the result is exact before the single final rounding. Leave out to_unit to get the value in every supported unit.

  • kB, MB, GB use powers of 1000 (SI); KiB, MiB, GiB use powers of 1024 (IEC). Operating systems that show 'GB' for powers of 1024 are really showing GiB.
  • Unit definitions: 1 bit = 1 bits (base unit); 1 B = 8 bits (8 bits (octet)); 1 kB = 8000 bits (SI prefix, 10³ bytes); 1 MB = 8000000 bits (10⁶ bytes); 1 GB = 8000000000 bits (10⁹ bytes); 1 TB = 8000000000000 bits (10¹² bytes); 1 PB = 8000000000000000 bits (10¹⁵ bytes); 1 EB = 8000000000000000000 bits (10¹⁸ bytes); 1 ZB = 8000000000000000000000 bits (10²¹ bytes); 1 KiB = 8192 bits (IEC prefix, 2¹⁰ bytes); 1 MiB = 8388608 bits (2²⁰ bytes); 1 GiB = 8589934592 bits (2³⁰ bytes); 1 TiB = 8796093022208 bits (2⁴⁰ bytes); 1 PiB = 9007199254740992 bits (2⁵⁰ bytes); 1 EiB = 9223372036854775808 bits (2⁶⁰ bytes); 1 ZiB = 9444732965739290427392 bits (2⁷⁰ bytes); 1 kbit = 1000 bits (10³ bits); 1 Mbit = 1000000 bits (10⁶ bits); 1 Gbit = 1000000000 bits (10⁹ bits); 1 Tbit = 1000000000000 bits (10¹² bits); 1 Kibit = 1024 bits (2¹⁰ bits); 1 Mibit = 1048576 bits (2²⁰ bits); 1 Gibit = 1073741824 bits (2³⁰ bits)

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Use it from your code

POST /v1/calc/units/data-sizeVersion 1
curl https://api.curatedapi.com/v1/calc/units/data-size \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "1",
    "from_unit": "GiB",
    "to_unit": "B"
  }'
The same call in Python
import os

import requests

payload = {
    "value": "1",
    "from_unit": "GiB",
    "to_unit": "B",
}
response = requests.post(
    "https://api.curatedapi.com/v1/calc/units/data-size",
    headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
    json=payload,
    timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
    "value": "1",
    "from_unit": "GiB",
    "to_unit": "B",
};
const response = await fetch("https://api.curatedapi.com/v1/calc/units/data-size", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log((await response.json()).result);

MCP tool calc_units_data_size at https://mcp.curatedapi.com. Inputs, outputs and errors in the API reference.

Put it on your website

<div data-curatedapi-widget="units/data-size" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>

Use a public key registered for your site. Calculations are billed like API calls. How widgets work.

Related calculators

Add this calculator to your website

Paste two lines into your page and your visitors get this calculator. Each use counts as one call on your plan, the same as the API.

Free for up to 1,000 uses a month. 50,000 uses a month cost $9.00 on the Starter plan.