bytes-fmt
v0.1.0
Published
Human-readable byte sizes (SI/IEC) and duration parse/format for CLI and logs
Maintainers
Readme
bytes-fmt
Format and parse byte sizes (SI/IEC) and human-readable durations for CLIs, logs, and dashboards. Uses Intl for locales. Zero dependencies.
import { formatBytes, parseBytes, formatDuration, parseDuration } from 'bytes-fmt';
formatBytes(1_536_000, { standard: 'iec' }); // e.g. "1.46 MiB"
parseDuration('1h 30m'); // 5_400_000 msInstall
npm install bytes-fmtAPI
formatBytes/parseBytes— SI (1000) or IEC (1024), optionallocaleformatDuration/parseDuration— milliseconds ↔1h 30mstyle strings
When to use
Disk usage output, upload progress, timeout messages, and ops tooling.
Why teams pick this
vs hand-rolled formatters: consistent IEC/SI byte strings and parsing without pulling in filesize for one label.
Search terms: bytes, humanize, file size, duration, parse duration, format bytes, mib, kb, cli, node
