Data size converter API
Convert between bits, bytes and their decimal (kB, MB) and binary (KiB, MiB) multiples.
POST https://api.curatedapi.com/v1/calc/units/data-size
- Version 1
- MCP tool
calc_units_data_size - Try it in the browser
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.
Formula
result = value × factor(from_unit) ÷ factor(to_unit), factors in bits
- 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)
Inputs
Send numbers as strings to keep every digit. options sets precision and rounding (see numbers and rounding).
| Input | Type | Description |
|---|---|---|
value required |
decimal (string) | The amount to convert. Allowed: >= 0. |
from_unit required |
bit | B | kB | MB | GB | TB | PB | EB | ZB | KiB | MiB | GiB | TiB | PiB | EiB | ZiB | kbit | Mbit | Gbit | Tbit | Kibit | Mibit | Gibit | 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 |
to_unit |
bit | B | kB | MB | GB | TB | PB | EB | ZB | KiB | MiB | GiB | TiB | PiB | EiB | ZiB | kbit | Mbit | Gbit | Tbit | Kibit | Mibit | Gibit | 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 |
options.rounding |
half_even | half_up | half_down | up | down | ceiling | floor | Rounding mode applied once to each result. Default half_even. |
options.decimals |
integer | Round results to this many digits after the decimal point. |
options.significant_digits |
integer | Round results to this many significant digits. |
Result
Under result in the answer, next to exactness, precision, inputs, formula, references and warnings.
| Result | Type | Description |
|---|---|---|
result | decimal (string) | The converted value. |
factor | decimal (string) | How many to_unit make one from_unit (multiply by this to convert). |
all_units | list of object | The value expressed in every supported unit. |
Examples
A '1 TB' drive in GiB
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": "TB",
"to_unit": "GiB"
}'
{
"calculator": "units/data-size@1",
"result": {
"result": "931.322574615479",
"factor": "931.322574615479"
},
"exactness": {
"result": "rounded",
"factor": "rounded"
},
"precision": {
"rounding": "half_even",
"significant_digits": 15
},
"inputs": {
"value": "1",
"from_unit": "TB",
"to_unit": "GiB"
},
"formula": "result = value × factor(from_unit) ÷ factor(to_unit), factors in bits",
"references": [
{
"title": "NIST: Prefixes for binary multiples (IEC kibi, mebi, gibi, ...)",
"url": "https://physics.nist.gov/cuu/Units/binary.html"
},
{
"title": "BIPM SI Brochure, 9th edition: SI prefixes",
"url": "https://www.bipm.org/en/publications/si-brochure"
}
],
"warnings": []
}
One GiB in bytes
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"
}'
{
"calculator": "units/data-size@1",
"result": {
"result": "1073741824",
"factor": "1073741824"
},
"exactness": {
"result": "exact",
"factor": "exact"
},
"precision": {
"rounding": "half_even",
"significant_digits": 15
},
"inputs": {
"value": "1",
"from_unit": "GiB",
"to_unit": "B"
},
"formula": "result = value × factor(from_unit) ÷ factor(to_unit), factors in bits",
"references": [
{
"title": "NIST: Prefixes for binary multiples (IEC kibi, mebi, gibi, ...)",
"url": "https://physics.nist.gov/cuu/Units/binary.html"
},
{
"title": "BIPM SI Brochure, 9th edition: SI prefixes",
"url": "https://www.bipm.org/en/publications/si-brochure"
}
],
"warnings": []
}
References
- NIST: Prefixes for binary multiples (IEC kibi, mebi, gibi, ...)
- BIPM SI Brochure, 9th edition: SI prefixes
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.
Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.