Convert JSON to MongoDB import format
Turn a JSON object or array into a "JSON Lines" file (one document per line), the format mongoimport expects. An _id in ObjectId format can be generated automatically for each document that doesn't already have one.
How it works
By default, mongoimport expects a JSON Lines file: one complete JSON document per line, with no commas or enclosing brackets (unlike a regular JSON array). Paste your array of objects and click "Convert": each object becomes an independent line, ready for the command mongoimport --db=my_db --collection=my_collection --file=import-mongodb.json.
Why use { "$oid": "..." } rather than ObjectId(...)?
ObjectId(...) is a JavaScript notation used in the Mongo shell, but it is not valid JSON. The { "$oid": "665f1a2b3c4d5e6f7a8b9c0d" } syntax is the "MongoDB Extended JSON" format officially recognized by mongoimport to represent an ObjectId in a standard JSON file.
What happens if a document already has an _id?
Its existing _id is kept as is, whether it is a string, a number or an $oid object: the tool only generates a new identifier for documents that have none, to avoid any conflict with identifiers already assigned on the application side.
100% local processing: conversion runs entirely in your browser — your data is never sent to a server.