bytes

Utility library for converting bytes to human-readable byte strings and parsing byte strings to numbers. Converts 1073741824 to '1GB', parses '1.5TB' to the numeric byte value. Used by Express.js, Koa, and body-parser internally for file size limits. Simple, focused, zero-dependency utility.

Evaluated Mar 06, 2026 (0d ago) v3.x
Homepage ↗ Repo ↗ Developer Tools bytes size formatting parse convert human-readable file-size
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
100
/ 100
Is it safe for agents?
⚡ Reliability
94
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
72
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
98
Secret Handling
100

Zero dependencies, MIT licensed. Pure computation — no security concerns.

⚡ Reliability

Uptime/SLA
100
Version Stability
95
Breaking Changes
92
Error Recovery
88
AF Security Reliability

Best When

You need a simple, reliable bytes-to-string and string-to-bytes converter that matches Express.js's size parsing behavior.

Avoid When

You need IEC binary prefixes (KiB, MiB, GiB) distinction or complex unit system conversions.

Use Cases

  • Display file sizes in human-readable format in agent file management interfaces
  • Parse user-provided byte size strings for configuring upload limits, memory limits, or data quotas
  • Convert programmatic byte values to display strings for agent monitoring dashboards
  • Validate and normalize size configuration values in agent middleware (e.g., 'limit: 10mb' → bytes number)
  • Format memory usage, network transfer sizes, or storage capacities in agent observability output

Not For

  • Complex unit conversions — bytes.js handles byte units only (B, KB, MB, GB, TB, PB)
  • Precise decimal/binary unit distinction — bytes.js uses 1KB=1000B (SI) by default in some versions; verify for your use case
  • Number formatting beyond file sizes — use numeral.js or Intl.NumberFormat for general number formatting

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Local library — no authentication required. MIT licensed.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT licensed. Zero cost. Zero dependencies.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • bytes(1000) returns '1KB' (1 decimal, uppercase) by default — use { thousandsSeparator: ',', unitSeparator: ' ' } options for different formatting
  • bytes.parse() accepts case-insensitive strings: '1.5 GB', '1.5GB', '1.5gb' all work — returns bytes as integer
  • Returns null for invalid input rather than throwing — check for null: const result = bytes.parse('invalid'); if (result === null) throw new Error('Invalid size')
  • 1KB = 1000 bytes (SI/decimal), not 1024 (binary/IEC) — bytes.js uses SI units; be explicit in documentation if your system uses binary KiB
  • bytes(0) returns '0B' — not '0 bytes' or empty string; check output format in your display context
  • bytes library is separate from the Node.js built-in Buffer size handling — no connection to Node.js buffer module

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for bytes.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered