NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

File Size Formatter API

GET

Give users clear file sizes instead of raw byte counts.

File Size Formatter converts raw byte counts into human-readable file size strings. Send a byte count with optional precision and unit settings to receive formatted labels, unit names, and scaled numeric values.

Try it — live request, no key required

Request
GETapi.apiverve.com/v1/filesizeformatter?bytes=1073741824
Query parameters
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "bytes": 1073741824,
    "formatted": "1 GiB",
    "value": 1,
    "unit": "GiB",
    "standard": "binary",
    "precision": 2,
    "conversions": {
      "B": 1073741824,
      "KiB": 1048576,
      "MiB": 1024,
      "GiB": 1,
      "TiB": 0,
      "PiB": 0,
      "EiB": 0,
      "ZiB": 0,
      "YiB": 0
    }
  }
}

About the File Size Formatter API

A file size formatter API for turning raw byte counts into labels people can read. Send a number of bytes and get back a formatted string such as "1.5 GiB", along with the numeric value, the unit it chose and the standard it used. It handles everyday conversions like bytes to MB or bytes to GB, in binary (MiB, GiB) or decimal (MB, GB) units, so a storage dashboard and a download page can each show the convention their users expect.

Typical uses are upload limits, disk usage reports, backup summaries and file listings where the database stores bytes but the interface needs KB, MB or GB. You can let the API pick the largest unit that keeps the value at 1 or above, or ask for a specific unit, and set how many decimal places to show.

The Free plan returns the formatted string, value, unit, standard and precision. Paid plans add a conversions object with the same byte count expressed in every unit from bytes to yottabytes, which saves a second call when a table needs several columns.

How it works

The divisor depends on standard: binary (the default) divides by 1024 and labels units B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB; any other value, including decimal, divides by 1000 and labels them B, KB, MB, GB, TB, PB, EB, ZB and YB. For every unit the API computes bytes / divisor^n and rounds it to precision decimal places with toFixed, then parses it back to a number, so trailing zeros are dropped: 1073741824 bytes gives value: 1, not 1.00.

When unit is not set, the API walks from the largest unit down and picks the first whose value is 1 or more. Values under 1 byte stay in B. When unit is set, it is matched case-insensitively against the label list of the chosen standard; a label that does not belong to that standard (for example MB with standard=binary) is not found, and the auto-selected unit is used instead without an error. formatted is value and unit joined by a space.

precision defaults to 2. Because rounding happens per unit, small results in large units round to 0, which is why a 1 GiB input shows TiB: 0 in conversions. The conversions object is keyed by the labels of the active standard and is returned as null on the Free plan.

What people use it for

File Management
Display file sizes in user-friendly formats in file managers and storage applications
Storage Analytics
Format storage usage data in dashboards and analytics reports
Data Transfer
Show download and upload sizes in appropriate units during file transfers
API Responses
Convert byte sizes to readable formats in API responses and data exports

Ways to call it

One endpoint, many ways in — REST with JSON, XML, YAML and CSV, plus GraphQL and an MCP interface for AI agents.

JSON
Default REST response
XML
Markup format
YAML
Human-readable
CSV
Tabular export
Beta
GraphQL
Query language
New
MCP
For AI agents

Other ways to use File Size Formatter

Same data, same APIVerve account, same credit balance — one key works on all of them.

Questions.

Common questions about the File Size Formatter API.

Read the docs →
Does it support both 1024-based binary and 1000-based decimal standards?
Yes, it supports binary calculations based on 1024 multipliers like KiB, MiB, and GiB as well as decimal standards based on 1000 multipliers like KB, MB, and GB. You can specify your preferred standard on each request.
Can I choose the target unit or customize the decimal places?
Yes, you can specify an exact target unit or omit it to let the system automatically select the cleanest unit. You can also configure precision between 0 and 10 decimal places to control rounding.
What size range does File Size Formatter support?
The API handles values starting from single bytes all the way up through yobibytes. It supports byte, kibibyte, mebibyte, gibibyte, tebibyte, pebibyte, exbibyte, zebibyte, and yobibyte tiers.
Is the multi-unit conversion table included on the Free plan?
No, the full conversions breakdown across all units is a premium feature. The Free plan returns the primary formatted string and unit value, while any paid plan unlocks the complete conversion table spanning bytes to yobibytes.
How far does the Starter plan go for file size conversions?
The Starter plan covers 200,000 conversions each month. Because each request uses 1 credit, calls work out to about $0.00015 each, or $0.15 per 1,000 calls. You can also test with 200 calls per month on the Free plan.

Ready to build with File Size Formatter? Start with 200 free credits — one key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs