audit-log-diff

Deep object diffs for audit logs

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

Audit-friendly change detection

From nested trees to human-readable sentences — one small library for change tracking.

Nested diffs

Tree-shaped change nodes — ideal for rendering hierarchical audit views.

Flat paths

Dot-notation paths for indexing, filters, and database storage.

Audit messages

Optional English log lines with spaced camelCase paths and 1-based row labels.

ignoreKeys

Skip noisy or sensitive fields like updatedAt and password at every depth.

Date equality

Same instant compares equal even when Date references differ.

Deep comparison

Objects, arrays (by index), Mongoose toObject(), and BSON .equals() values.

Built for

Activity and audit logsChange history trackingSystem event loggingDocument version diffsAdmin action trails

Install

Install from npm

bash
npm install audit-log-diff

Nested diff

typescript
import { 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" }
// }

Flat paths

typescript
const flat = deepDiff(before, after, { format: "flat" });
// [
//   { path: "profile.age", type: "changed", before: 36, after: 37 },
//   { path: "role", type: "added", value: "admin" }
// ]

Human-readable messages

typescript
const { diff, messages } = deepDiff(before, after, {
  generateMessage: true,
  user: "Dheemanth Shenoy",
});
// messages e.g. ["Dheemanth changed profile → age to 37", …]

Ready to track changes in your audit logs?

Browse the full API reference or try every function in the live playground.

Audit Log Diff

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.

© 2026 Audit Log Diff