object-hash

Deterministic SHA1/MD5 hashing for any JavaScript value or object, in Node.js and the browser.

Library
npm
v3.0.0
1,474stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
51/100Fair
Architecture60
Code Quality68
Innovation40
Learning Curve35

object-hash walks any JavaScript value — objects, arrays, Maps, Sets, Buffers, typed arrays, dates, functions, even circular references — and produces a stable hash of its contents rather than its reference. It ships as a single dependency-free module built on Node’s crypto module, with a browser build for client-side use, and exposes sugar methods (sha1, MD5, keys, keysMD5) plus a streaming API (writeToStream) for wiring the serialization into custom pipelines.

The library is commonly reached for wherever two structurally-equal-but-differently-ordered objects need to compare equal: cache keys derived from function arguments, change detection between two states of a config or Redux-style store, deduplicating similar-but-not-identical records, or grouping objects by their keys while ignoring values via excludeValues. Options like unorderedArrays, unorderedSets, and unorderedObjects (on by default) let callers decide whether ordering is semantically meaningful for their data before it factors into the hash.

Since v1.1.8 the project treats its exact hash output as part of its semver contract — any change that alters a produced hash for the same input is a major version bump — which matters for consumers who persist these hashes (as cache keys or stored fingerprints) across upgrades.

What You Get

  • A single hash(value, options) entry point covering objects, arrays, Maps, Sets, Buffers, typed arrays, dates, regexes, errors, and functions, plus explicit circular-reference detection.
  • Sugar methods hash.sha1(), hash.MD5(), hash.keys() (values-ignored, keys-only hashing for grouping), and hash.keysMD5() for the common cases without assembling an options object.
  • Fine-grained control over what counts toward the hash: excludeValues, excludeKeys(fn), replacer(fn), ignoreUnknown, and respectType/respectFunctionNames/respectFunctionProperties toggles.
  • Order-insensitivity switches — unorderedArrays, unorderedSets (on by default), unorderedObjects (on by default) — so structurally equal but differently-ordered collections can be made to hash the same.
  • A writeToStream(value, options, stream) API for piping the same internal serialization into a custom writable stream instead of only returning a digest.
  • Both a Node.js build (index.js, using the crypto module) and a bundled browser build (dist/object_hash.js) shipped in the same package.

Common Use Cases

  • Cache key generation - deriving a stable cache key from a function’s arguments or a request’s parameters so structurally identical calls hit the same cache entry.
  • Change/diff detection - hashing two snapshots of application state (e.g. a config object or store slice) to cheaply detect whether anything meaningful changed.
  • Deduplication - hashing incoming records to identify duplicates that differ only in key order or in fields the caller doesn’t care about (via excludeKeys/excludeValues).
  • Grouping by shape - using hash.keys() to group objects that share the same set of keys regardless of their values.

Under The Hood

Architecture The library is a single dependency-free module (index.js) built around one dispatch-based type visitor: typeHasher(options, writeTo, context) returns an object whose dispatch() method inspects a value’s runtime type (via Object.prototype.toString and typeof) and routes it to a matching _<type> handler (_object, _array, _map, _set, _date, _function, _buffer, and roughly two dozen Node-native-object handlers such as _tcp/_zlib/_httpparser). Circular references are handled by tracking visited objects in a context array and substituting a [CIRCULAR:n] marker; unordered collections are handled by re-serializing each entry through an isolated PassThrough-backed sub-hasher, sorting the resulting strings, then re-dispatching the sorted list. Writing itself is abstracted behind a small hand-rolled PassThrough shim so the same typeHasher code can target either a real crypto.Hash stream or an in-memory buffer used internally for the unordered-array sort. There is no layering beyond this one file — applyDefaults() normalizes options and validates the requested algorithm/encoding against crypto.getHashes(), and the exported sugar functions are thin wrappers that call objectHash() with preset options.

Tech Stack The runtime dependency footprint is zero — the Node build relies solely on the built-in crypto module (crypto.createHash, crypto.getHashes()) with no third-party packages. Everything else is dev tooling: browserify plus gulp (with gulp-uglify, gulp-rename, gulp-replace) to produce the browser bundle in dist/, karma with karma-chrome-launcher/karma-mocha to run the same test suite against a real browser, mocha for the Node test runner, and eslint (extending eslint:recommended, with curly/eqeqeq/no-caller tightened) for linting. CI (.github/workflows) runs the linter and browser build once, then re-runs the Mocha suite across a matrix of Node versions 8 through 21, reflecting the package’s long-lived commitment to old-runtime compatibility (engines.node >= 6).

Code Quality Test coverage is organized by concern across test/index.js (general API + options), test/types.js, test/object-classes.js, test/blob.js, test/replacer.js, test/old-crypto.js, and test/writeToStream.js, together exercising the majority of the type-dispatch branches and option combinations with plain Mocha describe/it blocks and Node’s assert. Error handling is explicit rather than swallowed: unsupported algorithms/encodings, a missing object argument, and unsupported Blob hashing all throw descriptive Errors rather than failing silently. There is no TypeScript and no type declarations shipped, naming is plain and consistent (_<type> handler convention), and ESLint plus a Node-version CI matrix act as the only quality gates beyond the test suite itself.

API Design The public surface is intentionally small: one primary hash(value, options) call plus four sugar wrappers (sha1, MD5, keys, keysMD5) that cover the most common option combinations without requiring callers to assemble an options object, and a writeToStream escape hatch for streaming consumers. Options are well-documented inline via JSDoc-style comments in index.js and default to sensible, conservative behavior (SHA1/hex, ordered arrays, keys respected) so the zero-argument case does the intuitive thing. The tradeoff is that the API leans on stringly-typed option flags (excludeValues, unorderedArrays, etc.) rather than separate composable functions, keeping the surface area minimal at the cost of some discoverability — a reader has to consult the README’s options table rather than infer behavior from distinct method names.

Used by 17 apps in this directory

TypeScript
68%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,825

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript68%
Java21%
Updated 3 days ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,884

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
61
Dependency
Built with
TypeScript97%
Updated yesterday
JavaScript
83%
Other

Countly

Analytics · Marketing

5,896

Privacy-first, self-hosted analytics and customer engagement platform with full data ownership, GDPR compliance, and AI-powered insights across mobile, web, desktop, and IoT.

View details
95
Repo Health
82
Technical
65
Dependency
Built with
JavaScript83%
Updated 3 days ago
TypeScript
81%
Other

Directus

CMS · Low Code Platforms

37,783

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
TypeScript81%
Vue18%
Updated 3 days ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,772

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript75%
Updated yesterday
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,427

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
86
Repo Health
77
Technical
63
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 3 weeks ago
TypeScript
97%
Other

Formbricks

Forms Surveys · Marketing · Analytics

12,897

Open-source experience management platform for in-app, website, email, and link surveys — privacy-first and fully self-hostable.

View details
93
Repo Health
81
Technical
70
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

484

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
89
Repo Health
81
Technical
69
Dependency
Built with
TypeScript99%
Updated 2 days ago
TypeScript
96%
MIT

HyperDX

Developer Tools · Analytics · Monitoring

9,873

Open source observability platform that unifies logs, traces, metrics, and session replays on ClickHouse — now the core of ClickStack.

View details
88
Repo Health
83
Technical
68
Dependency
Built with
TypeScript96%
Updated yesterday

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