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.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Zero dependencies, MIT licensed. Pure computation — no security concerns.
⚡ 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
Authentication
Local library — no authentication required. MIT licensed.
Pricing
MIT licensed. Zero cost. Zero dependencies.
Agent Metadata
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
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.