JSON-Patch

Lean, high-performance RFC 6902 JSON Patch and JSON Pointer implementation for applying, generating, validating, and observing diffs between JSON documents.

Library
npm
v3.1.1
1,982stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity0
Maintenance32
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture74
Code Quality68
Innovation72
Learning Curve60

fast-json-patch is a small, dependency-free implementation of the JSON Patch (RFC 6902) and JSON Pointer standards for JavaScript and TypeScript. It lets you apply an array of patch operations to a document, validate a sequence of operations before applying them, and compare two object trees to generate the minimal patch that turns one into the other — all useful for syncing partial updates over HTTP PATCH requests instead of shipping whole documents.

Beyond the core apply/compare/validate functions, it ships a duplex “observe” API that watches a live JavaScript object for mutations and synchronously emits the corresponding JSON Patch operations when you call generate(). The library ships as CommonJS, native ESM, and a minified browser bundle from the same TypeScript source, and its test suite runs the official json-patch-tests conformance fixtures to guarantee strict RFC 6902 compliance across Node.js and browsers (Chrome, Firefox, Safari, Edge, IE11).

What You Get

  • applyPatch / applyOperation for applying RFC 6902 operations to a document, with optional mutation vs. clone semantics
  • compare() to diff two JSON document trees and produce the minimal patch array between them
  • validate() to check a sequence of operations against a document and surface a typed JsonPatchError on the first invalid op
  • observe()/generate()/unobserve() for a duplex change-tracking API that emits patches as an object mutates
  • Full TypeScript typings for every operation kind (add, remove, replace, move, copy, test) as a discriminated union
  • Zero runtime dependencies and parallel CommonJS, ESM, and browser-bundle builds from one source tree

Common Use Cases

  • Sending partial updates to a REST API via HTTP PATCH instead of re-uploading the whole resource
  • Computing and storing an audit trail of changes made to a JSON document over time
  • Synchronizing client and server state by diffing local and remote copies of a document
  • Implementing optimistic UI updates that can be reverted by inverting a generated patch
  • Validating incoming JSON Patch payloads from third parties before applying them to internal state

Under The Hood

Architecture The implementation is split across three flat modules under src/: core.ts holds an operation-dispatch table (objOps/arrOps) mapping each RFC 6902 op name to a dedicated handler function, plus the public applyPatch/applyOperation/compare/validate entry points; duplex.ts layers a WeakMap-based “Mirror” shadow-copy mechanism on top of core.ts to power the observe()/generate() change-tracking API; and helpers.ts provides shared primitives (deep clone, path escaping, equality, the PatchError class) that both other modules import. There is no framework, dependency injection, or plugin system — the public index.ts simply re-exports and composes a default object from all three modules, and the design stays approachable because duplex.ts is the only layer built on top of core.ts rather than the reverse.

Tech Stack Written in TypeScript targeting es5 (tsconfig.json) with zero runtime dependencies, the same src/ tree is compiled three ways: a CommonJS package for Node/bundlers, a native ESM build (index.mjs) produced by a custom tsc-to-mjs.sh conversion script, and a minified UMD bundle via Webpack for direct browser <script> tags. Testing runs on Jasmine through a custom —experimental-modules runner (jasmine-run.mjs) and includes a Sauce Labs pipeline for real cross-browser verification against Chrome, Firefox, Safari, Edge, and IE11.

Code Quality The test suite is extensive — roughly 4,700 lines of Jasmine specs across core, duplex, and validation behavior — and additionally runs the official json-patch-tests conformance fixtures vendored under test/spec/json-patch-tests/ to guarantee strict RFC 6902 compliance. Error handling is explicit via a dedicated PatchError/JsonPatchError class rather than swallowed exceptions, and typings are thorough, modeling each operation kind as a discriminated union with a dedicated typingsSpec.ts test verifying the .d.ts surface compiles. There is no linter or formatter configuration checked in, and CI is a legacy Travis pipeline rather than a modern equivalent, consistent with the repo’s currently low commit activity despite its long history.

API Design The public surface is a small, consistent set of top-level functions (applyPatch, applyOperation, compare, validate, observe, generate) that all operate directly on a plain JS document with no required setup or configuration boilerplate, and a mutateDocument flag lets callers opt into either in-place mutation or a cloned result from the same call. The README documents every function with a runnable example, and both CommonJS and ESM entry points work without a bundler. The main friction point is the observe/generate duplex API, whose WeakMap+Mirror internals are powerful but less discoverable than the straightforward apply/compare functions, and represent an older idiom relative to newer Proxy-based change-tracking approaches.

Used by 13 apps in this directory

TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,260

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated 2 days ago
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
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,643

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript49%
Go45%
Updated today
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,299

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
63
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Lightdash

Analytics · Data Engineering

6,119

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript96%
Updated yesterday
TypeScript
88%
Apache 2.0

Medplum

Developer Tools · Databases · Authentication

2,657

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 yesterday
TypeScript
92%
Other

n8n

Automation · No Code Platforms

203,555

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today
TypeScript
50%
ZLIB

Portainer

Devops

38,446

A lightweight, open-source web UI that puts Docker, Kubernetes, and Podman management within reach of any team—no CLI expertise required.

View details
92
Repo Health
79
Technical
65
Dependency
Built with
TypeScript50%
Go38%
Updated 5 days ago
Rust
71%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,116

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
65
Dependency
Built with
Rust71%
TypeScript25%
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