# Bytes format human

`bytes-format-human` · version 1.0.0 · Other utilities · free, no key needed

Format an exact byte count as both SI and IEC strings and return the rounding mode used.

**Use when you need to: format bytes for humans · show bytes in SI and IEC · convert byte count to MB and MiB.**

## Decide before calling

Read the [versioned contract](/v1/tools/bytes-format-human/versions/1.0.0) and the supported scope below. Reuse `bytes-format-human@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `bytes-format-human@1.0.0` for format bytes for humans. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- format bytes for humans
- show bytes in SI and IEC
- convert byte count to MB and MiB
- make file size readable
- display exact bytes as units
- human readable byte count

## Not supported

- parse a human size
- convert data transfer rates

## Behavior

- After rounding, carry to the next SI/IEC unit if the rounded magnitude reaches its base (1000/1024), unless already at the largest supported unit. Recompute from exact bytes in the new unit.
- Select the largest unit whose integer multiplier does not exceed the byte count; SI uses powers of 1000 and IEC uses powers of 1024.
- precision is 0 to 6 fractional digits; half_even ties go to an even last digit, half_up ties increase, and down truncates.
- Outputs always include trailing fractional zeroes and a space before the unit.

## Input

- `bytes` (string, required): min length 1; max length 128; pattern `^(0|[1-9][0-9]*)$`
- `precision` (integer, required): min 0; max 6
- `rounding` (one of "half_even", "half_up", "down", required)

## Output

- `si` (string, required)
- `iec` (string, required)
- `rounding` (one of "half_even", "half_up", "down", required)
- `standard_version` (constant "IEC 80000-13:2008; SI Brochure, 9th edition (2019, updated 2022)", required)

## Limits

- max input bytes: 128
- max digits: 30
- max precision: 6
- max output bytes: 512
- max iterations: 12

## Example

Request input:

```json
{
  "bytes": "1500",
  "precision": 2,
  "rounding": "half_even"
}
```

Response:

```json
{
  "result": {
    "si": "1.50 kB",
    "iec": "1.46 KiB",
    "rounding": "half_even",
    "standard_version": "IEC 80000-13:2008; SI Brochure, 9th edition (2019, updated 2022)"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "bytes-format-human",
  "version": "1.0.0",
  "input": {
    "bytes": "1500",
    "precision": 2,
    "rounding": "half_even"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/bytes-format-human/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"bytes":"1500","precision":2,"rounding":"half_even"}'
```

The machine-readable contract is at [/v1/tools/bytes-format-human/versions/1.0.0](/v1/tools/bytes-format-human/versions/1.0.0).

### CLI

```sh
node cli.mjs run bytes-format-human 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Bytes parse human](/tools/bytes-parse-human): Parse an SI or IEC byte-size string and return an exact integer byte count using explicit rounding.
- [Data rate convert](/tools/data-rate-convert): Convert bit or byte rates across SI and IEC prefixes and return an exact reduced rational.
- [Base64url encode](/tools/base64url-encode): Encode supplied UTF-8 text or hexadecimal bytes as base64url and return the encoded string.
- [Array duplicates find](/tools/array-duplicates-find): List duplicated JSON values with counts and first indexes, preserving first-seen order.
- [Epoch to ISO](/tools/epoch-to-iso): Convert an exact integer Unix timestamp in seconds, milliseconds, microseconds or nanoseconds to RFC 3339 UTC.
- [Geohash convert](/tools/geohash-convert): Encode decimal coordinates as a bounded Geohash or decode a Geohash to its exact bounding box and midpoint.
