# File Size Formatter API

> 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.

**Endpoint:** `GET https://api.apiverve.com/v1/filesizeformatter`  
**Category:** Data Conversion  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/filesizeformatter

## Overview

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.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/filesizeformatter?bytes=1073741824&unit=GB&precision=2&standard=binary" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `bytes` | integer | Yes | Number of bytes to format. range 0-inf |
| `unit` | string | No | Specific target unit (optional, auto-selects best unit if not specified). One of: auto, B, KB, MB, GB, TB, PB, EB, ZB, YB |
| `precision` | integer | No | Decimal places (0-10). default 2. range 0-10 |
| `standard` | string | No | Standard to use: binary (1024) or decimal (1000). default binary. One of: binary, decimal |

## Response fields

- `bytes` — number · Original byte value in numeric format
- `formatted` — string · Formatted file size with unit as human-readable string
- `value` — number · Numeric value in the selected or auto-determined unit
- `unit` — string · File size unit used in the conversion (e.g., GiB, MB)
- `standard` — string · Standard used for conversion: binary or decimal
- `precision` — number · Decimal places applied to the formatted value
- `conversions` — object · Complete conversion table with values across all units · (premium)
  - `conversions.B` — number · The size expressed in bytes · (premium)
  - `conversions.KiB` — number · The size expressed in kibibytes (1024 bytes) · (premium)
  - `conversions.MiB` — number · The size expressed in mebibytes · (premium)
  - `conversions.GiB` — number · The size expressed in gibibytes · (premium)
  - `conversions.TiB` — number · The size expressed in tebibytes · (premium)
  - `conversions.PiB` — number · The size expressed in pebibytes · (premium)
  - `conversions.EiB` — number · The size expressed in exbibytes · (premium)
  - `conversions.ZiB` — number · The size expressed in zebibytes · (premium)
  - `conversions.YiB` — number · The size expressed in yobibytes · (premium)

## Sample response

```json
{
  "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
    }
  }
}
```

## Use cases

- **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

## SDKs

- **npm** — `npm install @apiverve/filesizeformatter` (https://www.npmjs.com/package/@apiverve/filesizeformatter)
- **NuGet** — `dotnet add package APIVerve.API.FileSizeFormatter` (https://www.nuget.org/packages/APIVerve.API.FileSizeFormatter)
- **Source** — https://github.com/apiverve/filesizeformatter-api

## More

- Full reference: https://docs.apiverve.com/ref/filesizeformatter
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
