bytes

Tiny utility for parsing and formatting byte strings like '1kb'

Library
npm
v3.1.2
476stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity0
Maintenance0
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
65/100Good
Architecture55
Code Quality75
Innovation40
Learning Curve90

bytes is a single-purpose Node.js utility that converts between numeric byte counts and human-readable byte strings — bytes.format(1024) returns '1KB', and bytes.parse('1kb') returns 1024. It supports the standard binary-prefix units (b, kb, mb, gb, tb, pb, using 1024-based multipliers) plus formatting options for decimal places, thousands separators, and unit separators.

At under 200 lines with zero runtime dependencies, it’s the kind of small, dependable utility that gets pulled in transitively by dozens of larger frameworks (including Express-ecosystem middleware) anywhere a byte size needs to move between a config string and a number.

What You Get

  • bytes.format(value, options) - convert a byte count into a formatted string like '1.5MB'
  • bytes.parse(value) - convert a byte string like '1kb' back into a numeric byte count
  • Format options for decimal places, fixed decimals, thousands separator, and unit separator
  • Support for all standard binary-prefix units from bytes through petabytes
  • Zero runtime dependencies and a small, auditable single-file implementation

Common Use Cases

  • Parsing human-friendly config values like maxFileSize: '10mb' into a numeric byte limit for upload middleware
  • Displaying human-readable file or transfer sizes in CLI tools and server logs
  • Validating request body size limits in HTTP frameworks (used transitively by several Express/Connect body-parsing middlewares)
  • Converting between raw byte counts and display strings in dashboards or admin UIs

Under The Hood

Architecture - The entire implementation lives in a single index.js: a fixed map object defines 1024-based multipliers per unit, format() picks the largest unit that fits the magnitude (or uses an explicit options.unit) and formats via toFixed plus optional thousands-separator regex post-processing, while parse() runs a single regex (parseRegExp) to extract a numeric value and unit suffix, falling back to a plain parseInt if the string doesn’t match a unit pattern.

Tech Stack - Plain, dependency-free JavaScript (CommonJS), with a test/ suite and standard .eslintrc linting; no build step is needed since the published package is the source file itself.

Code Quality - The code is compact, well-commented with JSDoc-style annotations for both public functions, and has a long-lived History.md documenting every release since 2012, suggesting careful, incremental maintenance rather than churn; there’s no runtime dependency to audit, which minimizes supply-chain surface area for consumers.

API Design - The API is about as low-friction as a utility can be: one function call in, one value out, with the same default export accepting either a string or number and dispatching accordingly, which is likely why it became a common transitive dependency across body-parsing and HTTP middleware in the Node ecosystem.

Used by 11 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,872

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
95
Repo Health
82
Technical
66
Dependency
Built with
TypeScript100%
Updated yesterday
TypeScript
80%
Other

Directus

CMS · Low Code Platforms

37,462

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
93
Repo Health
82
Technical
78
Dependency
Built with
TypeScript80%
Vue18%
Updated yesterday
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
99%
MIT

KeystoneJS

CMS · Developer Tools

9,957

The superpowered headless CMS for developers built with GraphQL and React

View details
91
Repo Health
81
Technical
64
Dependency
Built with
TypeScript99%
Updated yesterday
TypeScript
88%
Apache 2.0

Medplum

Developer Tools · Databases · Authentication

2,614

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
72
Dependency
Built with
TypeScript88%
MDX10%
Updated today
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

27,573

The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.

View details
97
Repo Health
86
Technical
68
Dependency
Built with
Python58%
TypeScript33%
Updated today
TypeScript
90%
AGPL 3.0

PeerTube

Social Media

15,270

A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.

View details
97
Repo Health
75
Technical
71
Dependency
Built with
TypeScript90%
Updated yesterday
JavaScript
86%
AGPL 3.0

SillyTavern

AI Assistants

32,350

The power-user LLM frontend that unifies dozens of AI backends with a rich scripting engine, immersive Visual Novel mode, and a thriving extension ecosystem.

View details
68
Repo Health
71
Technical
69
Dependency
Built with
JavaScript86%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search