Numbers math file size
Exactnumbers_math_file_sizeDeterministic and authoritative — the canonical answer for this input.
Parse a human file size ('2.5 GB', '2.5 MiB') or raw byte count and return a canonical payload: bytes, human form in the caller's base, and both SI (base 1000) and binary (base 1024) renderings. Handles the common GB-vs-GiB confusion explicitly.
Parameters
valuestringrequiredFile size as a human string ('2.5 GB') or raw byte count.
baseintegeroptional1000 (SI) or 1024 (binary) for the `human` output.
Call it
curl -X POST https://api.snipget.ai/v1/numbers/math/file-size \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"value":"2.5 GB"}'Example response
{
"input": "2.5 GB",
"is_valid": true,
"bytes": 2500000000,
"human": "2.50 GB",
"human_si": "2.50 GB",
"human_binary": "2.33 GiB",
"base": 1000
}FAQ
Why use this instead of converting in my head?
It settles the GB-versus-GiB confusion for you. A '2.5 GB' file is 2,500,000,000 bytes in SI terms but only 2.33 GiB in binary terms, and mixing the two is a constant source of wrong numbers. This returns the exact byte count plus both renderings so you never have to guess.
Can I go the other way, from bytes to a readable size?
Yes. Pass a raw byte count like 2684354560 (or the digit string '2684354560') and you get back a human label such as '2.50 GiB' alongside the SI and binary forms.
What units does it understand?
Bytes through petabytes, in both SI (KB, MB, GB, TB, PB) and binary (KiB, MiB, GiB, TiB, PiB) prefixes, case-insensitive, with or without a space before the unit. Both styles are accepted on input no matter which base you pick for the output.
Is the answer reliable, or just a rough estimate?
It is exact. This is a deterministic conversion, so the same input always returns the same authoritative byte count, never an approximation.
What happens if my input is gibberish?
You get a result marked is_valid false with a why_invalid reason and a confidence of 0, not an error. So 'banana' or an unknown unit comes back cleanly flagged rather than crashing your flow.