msgpackr

Ultra-fast MessagePack serialization for JavaScript with record structures for faster, more compact encoding.

Library
npm
v2.1.0
695 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
60 /100 Good
Development Activity 52
Maintenance 40
Community 60
Maturity 60
Momentum 28

Technical Analysis

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

msgpackr is a MessagePack serialization library for JavaScript built for raw throughput, reporting encode speeds over 1.5GB/s and decode speeds over 2GB/s on Node.js — faster than native JSON.stringify/parse and other MessagePack implementations in its own benchmarks. Its optional record structure extension automatically detects repeated object shapes and encodes them once as a shared, referenced definition instead of re-writing every key on each object, often more than doubling decode throughput and shrinking payload size 15-50% versus plain MessagePack maps.

It runs anywhere modern JavaScript runs — Node.js, Deno, Bun, and browsers — with an optional native addon that accelerates string parsing on Node while falling back transparently to pure JS elsewhere. Beyond the basic pack/unpack functions, it ships Transform streams for socket and IPC use, structured-clone support for cyclic references and typed objects like Set, Map, and Error, sync/async iterator helpers, and a custom extension API for encoding arbitrary classes.

What You Get

  • Standalone pack/unpack functions for drop-in MessagePack compatibility with any standard decoder
  • Packr/Unpackr classes with record structures, cross-session shared structures, and structured cloning
  • PackrStream/UnpackrStream NodeJS Transform streams plus sync/async iterator helpers (packIter/unpackIter)
  • Universal builds for Node, Deno, Bun, and browsers, including a CSP-safe no-eval variant
  • A custom extension API (addExtension) for encoding arbitrary classes under a reserved type code

Common Use Cases

  • Serializing structured, similarly-shaped records (logs, telemetry, clinical data) for storage with shared structures
  • High-throughput IPC or socket messaging using PackrStream/UnpackrStream
  • Replacing JSON.stringify/parse in performance-sensitive Node hot paths
  • Browser-to-server binary protocols where bandwidth matters more than gzip-friendliness

Under The Hood

Architecture msgpackr’s core is two tightly coupled modules — pack.js and unpack.js — that share module-level mutable state (the working buffer, read/write position, and structure/record-transition tables) to keep the encode/decode hot path allocation-free; Packr extends Unpackr so a single instance can both pack and unpack while sharing that structure state. node-index.js/index.js are thin entry points that pick Node-native acceleration (the optional msgpackr-extract addon) versus a pure-JS fallback, while stream.js layers NodeJS Transform streams and iterators.js layers sync/async generators on top of the same Packr/Unpackr primitives rather than reimplementing serialization separately. It’s a deliberately mutable-global, single-purpose codec design optimized for throughput over strict encapsulation — changing the record/structure-transition logic in pack.js or unpack.js ripples through every consumer (streams, iterators, structured clone) since they all read the same shared state directly.

Tech Stack The library has no required runtime dependencies beyond the optional native addon msgpackr-extract for accelerated string extraction; it’s authored as ESM ("type": "module") and built to CJS/UMD with Rollup (@rollup/plugin-json, @rollup/plugin-replace, @rollup/plugin-terser), producing separate bundles for Node, browser, and a CSP-safe -no-eval variant via a string-replace pass that swaps out dynamic Function construction. Conditional exports map map node/bun/browser/types entry points per consumer, and typing is hand-authored (index.d.ts, pack.d.ts, unpack.d.ts) rather than compiler-generated. Tests run under Mocha with Chai assertions.

Code Quality The test suite is substantial — a 1500+ line Mocha/Chai file covering pack/unpack round-trips, record structures, and 32-bit float handling, plus dedicated files for streaming, async iterators, incomplete/partial buffer reads, and cross-runtime compatibility (Bun, Deno, and a separate compatibility-format test). Error handling favors explicit, descriptive thrown Errors (for example on exceeding the maximum shared-structure count) over silent failures, and the incomplete-read path is modeled explicitly through an error.incomplete flag with a lastPosition offset rather than a generic exception. That said, no CI workflow configuration or linter/formatter config is present in the repository, and the TypeScript declaration files are hand-maintained rather than checked against the implementation by a compiler.

API Design The standalone pack/unpack functions cover the common case with zero configuration, and encoder/decoder terminology aliases (encode/decode, Encoder/Decoder) ease the transition for developers coming from other codecs. The Packr/Unpackr classes progressively unlock record structures, persisted shared structures, and structured cloning without complicating the basic API, and the README documents every option in a single reference table. Persisted shared structures require a small amount of boilerplate (getStructures/saveStructures callbacks), but that’s inherent to the optimization rather than accidental API complexity.

Used by 5 apps in this directory

TypeScript
93%
MIT

bunqueue

Developer Tools · Devops

570

High-performance job queue for Bun — SQLite persistence, cron scheduling, DLQ, S3 backups, and a native MCP server, all without Redis.

View details
73
Repo Health
83
Technical
72
Dependency
Built with
TypeScript 93%
Updated 3 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 5 days ago
TypeScript
95%
Apache 2.0

Enclosed

Security

2,090

Send end-to-end encrypted notes and files where the server never sees your content — true zero-knowledge sharing.

View details
57
Repo Health
88
Technical
71
Dependency
Built with
TypeScript 95%
Updated 1 weeks ago
Rust
37%
Other

Hook0

Devops

1,491

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
82
Repo Health
82
Technical
69
Dependency
Built with
Rust 37%
TypeScript 12%
Updated 1 weeks ago
TypeScript
61%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,797

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 61%
Svelte 34%
Updated 6 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