JSON Formatter for MongoDB Documents and Query Results
MongoDB stores data as BSON — Binary JSON — but outputs it as extended JSON when you work with the mongo shell, MongoDB Compass, or Atlas Data Explorer. That extended JSON includes type wrappers like `{ "$oid": "..." }` for ObjectIds and `{ "$date": "..." }` for Date fields, which can make already-complex documents even harder to read when they're packed into a single line. This formatter handles MongoDB's extended JSON output gracefully, expanding all nested sub-documents and arrays into a clear hierarchy. It's particularly useful when you're inspecting the output of an aggregation pipeline, reviewing a document returned by `db.collection.findOne()`, or debugging a schema design by looking at real document samples side by side. Paste your raw document output from the mongo shell or Atlas and get an immediately readable view of your data model.
Open JSON Formatter →What Is JSON Formatter for MongoDB Documents and Query Results?
MongoDB JSON formatting means expanding the compact output of MongoDB query results — including BSON extended JSON type wrappers like `$oid`, `$date`, and `$numberDecimal` — into an indented, human-readable structure. This helps developers understand document shape, design schemas, and debug aggregation pipelines.
How to Use the JSON Formatter
- Step 1: Run your MongoDB query in the mongo shell, Compass, or Atlas and copy the result document or array.
- Step 2: Paste the raw output into the input area above.
- Step 3: Click 'Format' to expand the document into its full nested structure.
- Step 4: Identify nested sub-documents, embedded arrays, and BSON type wrappers like $oid and $date.
- Step 5: Use the formatted view to verify your document schema matches your application's data model expectations.
- Step 6: Copy the formatted document to use in documentation, schema diagrams, or bug reports.
Example
{
"_id": { "$oid": "664a1f2e8c3d4e5f6a7b8c9d" },
"username": "dev_user_42",
"email": "dev@example.com",
"createdAt": { "$date": "2026-01-15T08:22:00Z" },
"profile": {
"firstName": "Priya",
"lastName": "Nair",
"bio": "Full-stack developer"
},
"tags": ["mongodb", "nodejs", "react"],
"karma": { "$numberInt": "1420" }
}
Pro Tips
- MongoDB's extended JSON uses `$oid`, `$date`, `$numberDecimal`, and similar type wrappers — the formatter will display them as nested objects, which is correct behavior.
- When comparing documents across collections, format both side by side to quickly spot schema inconsistencies between documents that should share a structure.
- ObjectId fields (`$oid`) contain the creation timestamp in the first 8 hex characters — formatting the document makes these visible for quick auditing.
- If your aggregation pipeline produces unexpected shapes, paste the output document here to see exactly what each pipeline stage is emitting.
- For schema design reviews, format a sample document from each collection you're reviewing — the nested structure reveals embedding decisions that are hard to see in tabular views.
Ready to Try It?
Free, browser-based, no signup required.
Launch JSON Formatter Free →FAQ's
BSON (Binary JSON) is MongoDB's internal storage format, supporting additional types like ObjectId, Date, Decimal128, and Binary that standard JSON lacks. When MongoDB outputs data as text, it uses Extended JSON to represent these types with special `$`-prefixed wrappers.
Yes. Copy the array of documents returned by an aggregation query — whether from the mongo shell, Compass, or a driver output — and paste it here. The formatter handles both single documents and arrays of documents correctly.
MongoDB's Extended JSON represents ObjectId as `{ "$oid": "hex_string" }`. This is correct and expected — the formatter is showing you exactly what MongoDB outputs. Your application driver converts these back to native ObjectId types automatically.
In Atlas, open the Collections tab, click on a document, and use the JSON view to copy the raw document. Paste it here for formatting. The Atlas editor formats documents inline, but this tool is useful for sharing or documenting the structure externally.
Absolutely. Write a sample document representing your intended schema, paste it here to validate the JSON structure, and use the formatted view to review nesting depth, field naming conventions, and embedded array structures before implementing them in your application.
Yes — MongoDB Date fields appear as `{ "$date": "ISO-string" }` in Extended JSON. The formatter displays these as nested objects, which accurately reflects the extended JSON format. The actual date value is the string inside the `$date` key.
MongoDB documents are capped at 16MB by BSON limits. The browser-based formatter can handle documents of this size, though very large documents may take a moment to render. The tool runs entirely in your browser — no data is sent to a server.