Compare MongoDB Documents Online
Paste two MongoDB documents. See what was added, removed, or changed — field by field, including nested subdocuments.
🔒 100% private — runs entirely in your browseror try sample data
Paste two MongoDB documents. See what was added, removed, or changed — field by field, including nested subdocuments.
🔒 100% private — runs entirely in your browseror try sample data
MongoDB Document Diff compares two MongoDB documents and shows you exactly which fields were added, removed, or modified — including deeply nested embedded documents and arrays of subdocuments. Whether you are tracking how a user profile evolved over time, detecting schema drift across a collection, or auditing changes made by an update operation, this tool gives you a clear, color-coded view of every difference.
MongoDB's flexible schema is both a strength and a challenge. Documents in the same collection can have entirely different field sets, nested structures can grow unpredictably, and update operations can touch fields deep inside embedded arrays. Manually comparing two documents by reading raw JSON is slow and error-prone, especially when documents contain dozens of fields and multiple nesting levels. This tool walks every path in both documents and surfaces every change.
Export your documents from mongosh, MongoDB Compass, mongoexport, or your application logs. The tool handles standard JSON as well as MongoDB Extended JSON (canonical and relaxed formats). Everything runs in your browser — your database documents are never sent to any server, making it safe for production data.
# Export a specific document from mongosh
db.users.findOne({ _id: ObjectId("507f1f77bcf86cd799439011") }) # Or use mongoexport for JSON output
mongoexport --db=myapp --collection=users \ --query='{"_id": {"$oid": "507f1f77bcf86cd799439011"}}' \ --jsonFormat=relaxed --pretty # From MongoDB Compass: right-click a document
# and select "Copy Document" to get JSON # Paste the before/after versions into the diff toolUse --jsonFormat=relaxed for human-readable output where ObjectIds and Dates appear as strings. Use --jsonFormat=canonical for exact type-preserving Extended JSON.
// Document from 2023 (older schema)
{ "_id": "abc123", "name": "Widget", "price": 29.99, "category": "hardware"
} // Document from 2024 (newer schema)
{ "_id": "def456", "name": "Gadget", "price": 49.99, "category": "hardware", "tags": ["featured", "new"], "metadata": { "weight": 0.5, "dimensions": { "w": 10, "h": 5, "d": 3 } }
} // Diff reveals: tags and metadata fields are missing
// from older documents = schema driftComparing documents created at different times reveals how your schema has evolved. Fields present in newer documents but absent from older ones indicate drift that may need migration.
// Before: db.users.updateOne(
// { _id: "507f1f77bcf86cd799439011" },
// {
// $set: { "profile.bio": "Staff engineer" },
// $push: { roles: "moderator" },
// $inc: { "loyalty.points": 500 }
// }
// ) // Copy the document before and after the update.
// Paste both into the diff tool to verify:
// - Only intended fields were modified
// - $push added to the correct array
// - $inc incremented the right value
// - No side effects from middleware or triggersMongoDB update operators like $set, $push, and $inc can have unexpected results when combined with middleware, change streams, or Atlas triggers. Always verify the actual before-and-after state.
MongoDB documents use BSON types like ObjectId, ISODate, NumberLong, and Binary that do not exist in standard JSON. When exported, these become either Extended JSON objects ({"$oid": "..."}) or plain strings depending on the export format. The diff tool compares whatever JSON representation you paste — just be consistent with both documents using the same export format.
MongoDB does not guarantee array element ordering in query results unless you use $sort in aggregation or sort within $push. Two exports of the same document might show arrays in different orders. Use the "Ignore array order" option to focus on content changes rather than ordering noise.
MongoDB preserves the insertion order of fields within documents, but JSON parsers may reorder keys alphabetically. Two documents with the same fields in different order will produce field-by-field differences that are not meaningful. This tool compares by key name, not position, so field ordering does not affect the diff result.
Export both documents as JSON using mongosh, MongoDB Compass, or mongoexport. Paste them into the two panels and click Compare. The tool highlights every added, removed, and modified field, including deeply nested embedded documents and arrays of subdocuments.
Yes. Since MongoDB is schemaless, documents in the same collection can have different fields. Comparing two documents side by side highlights missing fields, extra fields, and type differences — the key indicators of schema drift that may require data migration.
When exporting with mongoexport --jsonFormat=canonical, ObjectIds appear as {"$oid": "..."} and dates as {"$date": "..."}. With relaxed format, they appear as plain strings. The tool compares them as regular JSON values. Use the same export format for both documents for a meaningful comparison.
Yes. This tool runs entirely in your browser using client-side JavaScript. Your MongoDB documents, including personally identifiable information and internal business data, are never sent to any server.
Yes. You can compare any two JSON documents regardless of which collection, database, or even cluster they came from. This is useful for comparing equivalent records across environments (staging vs production) or verifying data migration results.
For documents containing large arrays (hundreds of elements), the diff tool compares each element at its index position. Enable "Ignore array order" if the array represents a set rather than an ordered list. For very large arrays, consider extracting just the array field for comparison to improve readability.