![]() |
VOOZH | about |
dotnet add package Ivy.NativeJsonDiff --version 2.0.0
NuGet\Install-Package Ivy.NativeJsonDiff -Version 2.0.0
<PackageReference Include="Ivy.NativeJsonDiff" Version="2.0.0" />
<PackageVersion Include="Ivy.NativeJsonDiff" Version="2.0.0" />Directory.Packages.props
<PackageReference Include="Ivy.NativeJsonDiff" />Project file
paket add Ivy.NativeJsonDiff --version 2.0.0
#r "nuget: Ivy.NativeJsonDiff, 2.0.0"
#:package Ivy.NativeJsonDiff@2.0.0
#addin nuget:?package=Ivy.NativeJsonDiff&version=2.0.0Install as a Cake Addin
#tool nuget:?package=Ivy.NativeJsonDiff&version=2.0.0Install as a Cake Tool
The fastest JSON diff and patch library for .NET — powered by native Rust.
A high-performance, zero-overhead alternative to JsonDiffPatch.Net, SystemTextJson.JsonDiffPatch, and JsonPatch.Net. Computes RFC 6902 JSON Patch diffs at native speed via Rust FFI.
Most .NET JSON diff libraries run entirely in managed code — parsing JSON trees, walking nodes, allocating intermediate objects, and producing diffs in the GC-managed heap. Ivy.NativeJsonDiff takes a fundamentally different approach: the entire diff and patch computation runs in native Rust, where there is no garbage collector, no boxing, and no allocation overhead.
| Ivy.NativeJsonDiff | JsonDiffPatch.Net | SystemTextJson.JsonDiffPatch | JsonPatch.Net | |
|---|---|---|---|---|
| Engine | Native Rust FFI | Managed (.NET) | Managed (.NET) | Managed (.NET) |
| JSON library | System.Text.Json | Newtonsoft.Json | System.Text.Json | System.Text.Json |
| RFC 6902 | Yes | No (custom format) | Optional | Yes |
| Patch apply | Yes | Yes | Yes | Yes |
| Allocations | Minimal (FFI boundary only) | High (JToken graph) | Medium (JsonNode graph) | Medium (JsonNode graph) |
| Platforms | win/linux/osx, x64/arm64 | Any | Any | Any |
NativeJsonDiff is benchmarked against every major .NET JSON diff library using BenchmarkDotNet across 9 payload categories (Small, Medium, Large, DeepNested, ArrayHeavy, ApiResponse, ConfigFile, LargeStateTree, VeryLargeStateTree — up to 2MB JSON trees).
Run benchmarks yourself:
cd src/Ivy.NativeJsonDiff.Benchmarks
dotnet run -c Release
Three benchmark suites are included:
Benchmarks run on every release. Results are published as GitHub Actions artifacts on the Releases page.
dotnet add package Ivy.NativeJsonDiff
Works out of the box on:
No native toolchain required — pre-compiled Rust binaries are bundled in the NuGet package.
using System.Text;
using System.Text.Json.Nodes;
using Ivy.NativeJsonDiff;
var oldJson = Encoding.UTF8.GetBytes("""
{
"name": "Alice",
"age": 30,
"roles": ["admin", "user"]
}
""");
var newJson = Encoding.UTF8.GetBytes("""
{
"name": "Alice",
"age": 31,
"roles": ["admin", "user", "moderator"]
}
""");
JsonNode? patch = JsonDiffer.ComputePatch(oldJson, newJson);
Console.WriteLine(patch);
// [
// {"op":"replace","path":"/age","value":31},
// {"op":"add","path":"/roles/2","value":"moderator"}
// ]
var document = Encoding.UTF8.GetBytes("""{"name":"Alice","age":30}""");
var patch = Encoding.UTF8.GetBytes("""[{"op":"replace","path":"/age","value":31}]""");
JsonNode? result = JsonDiffer.ApplyPatch(document, patch);
Console.WriteLine(result);
// {"name":"Alice","age":31}
public static class JsonDiffer
{
// Compute RFC 6902 JSON Patch diff between two JSON documents
static JsonNode? ComputePatch(byte[] oldTreeBytes, byte[] newTreeBytes);
// Apply an RFC 6902 JSON Patch to a JSON document
static JsonNode? ApplyPatch(byte[] jsonBytes, byte[] patchBytes);
}
Both methods accept UTF-8 encoded JSON as byte[] and return System.Text.Json.Nodes.JsonNode?. Returns null for identical documents or invalid input.
byte[] input is pinned and passed directly to Rust via C FFI (P/Invoke) — no managed copyserde_json::Value and runs json_patch::diff() (RFC 6902)JsonNodeThe native library is stateless — no background processes, no server, no shared memory. Pure function calls.
// Before (JsonDiffPatch.Net + Newtonsoft.Json)
var jdp = new JsonDiffPatch();
JToken diff = jdp.Diff(JToken.Parse(oldJson), JToken.Parse(newJson));
// After (Ivy.NativeJsonDiff + System.Text.Json)
JsonNode? patch = JsonDiffer.ComputePatch(
Encoding.UTF8.GetBytes(oldJson),
Encoding.UTF8.GetBytes(newJson));
// Before
JsonNode diff = JsonNode.Parse(oldJson).Diff(JsonNode.Parse(newJson));
// After
JsonNode? patch = JsonDiffer.ComputePatch(
Encoding.UTF8.GetBytes(oldJson),
Encoding.UTF8.GetBytes(newJson));
// Before
JsonPatch patch = JsonNode.Parse(oldJson).CreatePatch(JsonNode.Parse(newJson));
// After (same RFC 6902 format, much faster)
JsonNode? patch = JsonDiffer.ComputePatch(
Encoding.UTF8.GetBytes(oldJson),
Encoding.UTF8.GetBytes(newJson));
cd src/RustServer && cargo build --release
cd ../Ivy.NativeJsonDiff && dotnet build
dotnet test
cd src/Ivy.NativeJsonDiff.Benchmarks
dotnet run -c Release
MIT — see
json diff, json patch, json compare, RFC 6902, json merge patch, json diff dotnet, json patch dotnet, json diff csharp, json patch csharp, system.text.json diff, system.text.json patch, newtonsoft json diff, json diff performance, json diff benchmark, native json diff, rust json diff, fast json diff, json structural diff, json deep compare, json delta, json changeset, jsondiffpatch alternative, JsonDiffPatch.Net alternative, SystemTextJson.JsonDiffPatch alternative, JsonPatch.Net alternative
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Ivy.NativeJsonDiff:
| Package | Downloads |
|---|---|
|
Ivy
Build Internal Applications with AI and Pure C# |
Showing the top 1 popular GitHub repositories that depend on Ivy.NativeJsonDiff:
| Repository | Stars |
|---|---|
|
Ivy-Interactive/Ivy-Framework
The ultimate framework for building internal tools with LLM code generation by unifying front-end and back-end into a single C# codebase.
|