Nested diffs
Tree-shaped change nodes — ideal for rendering hierarchical audit views.
Deep-compare two values and get audit-style diffs: nested trees or flat paths, optional English log lines, Date equality by time, and per-level ignoreKeys.
3
Exported functions
2
Output formats
0
Runtime dependencies
Features
From nested trees to human-readable sentences — one small library for change tracking.
Tree-shaped change nodes — ideal for rendering hierarchical audit views.
Dot-notation paths for indexing, filters, and database storage.
Optional English log lines with spaced camelCase paths and 1-based row labels.
Skip noisy or sensitive fields like updatedAt and password at every depth.
Same instant compares equal even when Date references differ.
Objects, arrays (by index), Mongoose toObject(), and BSON .equals() values.
Install
npm install audit-log-diffimport { deepDiff } from "audit-log-diff";
const diff = deepDiff(
{ name: "Ada", profile: { age: 36 } },
{ name: "Ada", profile: { age: 37 }, role: "admin" },
);
// {
// profile: { age: { type: "changed", before: 36, after: 37 } },
// role: { type: "added", value: "admin" }
// }const flat = deepDiff(before, after, { format: "flat" });
// [
// { path: "profile.age", type: "changed", before: 36, after: 37 },
// { path: "role", type: "added", value: "admin" }
// ]const { diff, messages } = deepDiff(before, after, {
generateMessage: true,
user: "Dheemanth Shenoy",
});
// messages e.g. ["Dheemanth changed profile → age to 37", …]Browse the full API reference or try every function in the live playground.