Data Storage Units
18 data storage units covering both the decimal (SI) and binary (IEC 80000-13) systems: the universal bit and byte, decimal prefixed units (KB, MB, GB, TB, PB, EB, ZB, YB) where each step is a power of 1000, and their binary counterparts (KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB) where each step is a power of 1024. Byte counts are stored as strings to preserve precision for large values beyond JavaScript's safe integer range.
Quick fetch
Stable URL. CORS-enabled. No auth.
curl https://staticdata.dev/v1/data-units.json
Or use as a typed import:
import { dataUnits } from "https://staticdata.dev/v1/data-units.ts"
Formats
- JSON 1.9 KB
/v1/data-units.json
min: 1.3 KB · /v1/data-units.min.json
- CSV 644 B
/v1/data-units.csv
- TypeScript 2.1 KB
/v1/data-units.ts
export const dataUnits
type DataUnit = (typeof dataUnits)[number]
Schema
Each record in the dataset has the following shape.
| Field | Type | Description | Example |
|---|---|---|---|
| name | string | Full name of the unit (e.g. Kilobyte, Kibibyte) | Kilobyte |
| symbol | string | Standard symbol/abbreviation (e.g. KB, KiB) | KB |
| bytes | string | Exact number of bytes as a string to preserve precision for large values | 1000 |
| system | string | Prefix system: decimal (powers of 1000), binary (powers of 1024), or both (bit and byte) | decimal |
Preview
First 10 records.
| name | symbol | bytes | system |
|---|---|---|---|
| Bit | b | 0.125 | both |
| Byte | B | 1 | both |
| Kilobyte | KB | 1000 | decimal |
| Kibibyte | KiB | 1024 | binary |
| Megabyte | MB | 1000000 | decimal |
| Mebibyte | MiB | 1048576 | binary |
| Gigabyte | GB | 1000000000 | decimal |
| Gibibyte | GiB | 1073741824 | binary |
| Terabyte | TB | 1000000000000 | decimal |
| Tebibyte | TiB | 1099511627776 | binary |
Fetch examples
Drop-in snippets in five languages.
curl -sSL https://staticdata.dev/v1/data-units.json | jq '.[0]' import type { DataUnit } from "https://staticdata.dev/v1/data-units.ts";
const res = await fetch("https://staticdata.dev/v1/data-units.min.json");
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
const dataUnits: DataUnit[] = await res.json();
console.log(dataUnits[0]); import urllib.request, json
with urllib.request.urlopen("https://staticdata.dev/v1/data-units.min.json") as r:
dataUnits = json.load(r)
print(dataUnits[0]) package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("https://staticdata.dev/v1/data-units.min.json")
if err != nil { panic(err) }
defer resp.Body.Close()
var data []map[string]any
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
panic(err)
}
fmt.Println(data[0])
} use serde_json::Value;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let body = ureq::get("https://staticdata.dev/v1/data-units.min.json").call()?.into_string()?;
let data: Vec<Value> = serde_json::from_str(&body)?;
println!("{:?}", data.first());
Ok(())
} Sources and methodology
This dataset was curated from the IEC 80000-13:2008 international standard, which incorporates the binary prefixes (kibi-, mebi-, gibi-, etc.) that the IEC first introduced in 1998 to eliminate ambiguity between decimal and binary interpretations of units like “kilobyte”. The decimal SI prefixes follow the International System of Units where each step multiplies by exactly 1000.
The bytes field is stored as a string rather than a number because values at the zettabyte and yottabyte scale exceed JavaScript’s Number.MAX_SAFE_INTEGER (2^53 - 1). For example, 1 YiB = 1,208,925,819,614,629,174,706,176 bytes, which cannot be represented exactly as a 64-bit float. Callers that need arithmetic on these values should use BigInt in JavaScript or an arbitrary-precision library. The bit (b) and byte (B) entries use system: "both" since they are foundational units shared by both systems.
A common source of confusion is that operating systems historically reported file sizes using binary units but labelled them with decimal symbols (e.g., Windows reports 1 GiB as “1 GB”). Some systems (macOS, many Linux tools, drive manufacturers) now use decimal units, while others still label binary multiples with decimal symbols, so the ambiguity persists. In this dataset KB/MB/GB etc. always mean 10^3/10^6/10^9 bytes, and KiB/MiB/GiB etc. always mean 2^10/2^20/2^30 bytes. Note that the SI symbol for the kilo prefix is lowercase (kB); the uppercase KB used here is the common industry spelling. The 2022 SI prefixes ronna (10^27) and quetta (10^30) are not included, since no corresponding binary prefixes have been standardised.
Versioning
URLs under /v1/ are stable: field names and types will not change in a way
that breaks consumers. Values can be corrected or records added when the upstream source
changes; schema-incompatible updates ship under a new version path. See the
data-units changelog for this dataset's history.
More Code datasets
- ansi-colors
- ascii
- cron-presets
- css-at-rules
- css-functions
- css-named-colors
- css-properties
- css-pseudo-classes
- css-pseudo-elements
- css-units
- exit-codes
- file-signatures
- hash-algorithms
- js-array-methods
- js-math-methods
- js-object-methods
- js-string-methods
- json-schema-keywords
- jwt-claims
- mathematical-constants
- measurement-units
- node-builtin-modules
- owasp-top-10
- periodic-table
- physical-constants
- posix-signals
- programming-languages
- regex-flags
- regex-patterns
- roman-numerals
- si-base-units
- si-derived-units
- si-prefixes
- spdx-licenses
- strftime-tokens
- tailwind-colors
- time-units
- unicode-blocks
- unicode-general-categories
- unicode-planes
- unix-file-permissions
- xterm-256-colors