How to unflatten flat json into nested mongodb documents
- Step 1Prepare the flat dot-notation document — Paste the flat JSON with dot-separated keys. MongoDB dot-notation is the standard export format for many ETL tools and analytics pipelines.
- Step 2Select dot as the separator — Choose '.' as the key separator so the unflattener knows to split at each dot and reconstruct the nested map at each level.
- Step 3Verify the reconstructed document — Review the output to confirm embedded subdocuments are correctly nested and array elements with indexed keys (items.0, items.1) have been reconstructed as proper arrays.
- Step 4Import with mongoimport or bulk write — For single documents, use the MongoDB shell insertOne(). For bulk import, save the output as NDJSON and run mongoimport --db mydb --collection users --file restored.ndjson.
Frequently asked questions
How are MongoDB ObjectId values handled in the flattened and restored JSON?+
ObjectId values appear as strings in flattened exports (e.g. _id: '507f1f77bcf86cd799439011'). The unflattener preserves them as strings. When writing to MongoDB via the Admin SDK or mongoimport, you may need to wrap these with ObjectId() in your import script depending on whether the _id field requires a proper ObjectId type.
What about arrays of embedded documents?+
Arrays of embedded documents with indexed dot notation (orders.0.item, orders.0.qty, orders.1.item) are correctly reconstructed as arrays of nested objects. This matches MongoDB's document array structure and is compatible with $unwind and $lookup aggregation pipeline stages.
Is the MongoDB document data transmitted to JAD Apps?+
No. JSON unflattening runs entirely in your browser. Document data, user profiles, and any PII are never transmitted to JAD Apps servers.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.