bytes

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

Library
npm
v3.1.2
474 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
36 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 64
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
65 /100 Good
Architecture 55
Code Quality 75
Innovation 40
Learning Curve 90

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
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

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
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 6 days ago
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,924

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
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
TypeScript
79%
Other

Directus

CMS · Low Code Platforms

37,987

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
92
Repo Health
82
Technical
76
Dependency
Built with
TypeScript 79%
Vue 19%
Updated 1 weeks ago
TypeScript
95%
AGPL 3.0

Docmost

CMS · Collaboration · Note Taking

21,801

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
69
Dependency
Built with
TypeScript 95%
Updated 6 days ago
TypeScript
99%
MIT

KeystoneJS

CMS · Developer Tools

9,982

The superpowered headless CMS for developers built with GraphQL and React

View details
92
Repo Health
81
Technical
64
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
88%
Apache 2.0

Medplum

Authentication · Databases · Developer Tools

2,709

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
TypeScript 88%
Updated 6 days ago
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

28,154

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
66
Dependency
Built with
Python 58%
TypeScript 33%
Updated 5 days ago
TypeScript
91%
AGPL 3.0

PeerTube

Social Media

15,340

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
96
Repo Health
75
Technical
70
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
JavaScript
86%
AGPL 3.0

SillyTavern

AI Assistants

33,853

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
91
Repo Health
71
Technical
67
Dependency
Built with
JavaScript 86%
Updated 1 weeks 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