Import CSV into MongoDB
NDJSON, array
or insertMany().
Free CSV to MongoDB converter. Generates NDJSON for mongoimport, JSON Array or mongosh insertMany(). Type coercion, dot-notation nested documents, ready-to-run mongoimport command. Compatible with MongoDB Atlas, Community and local. Your data never leaves your browser.
Choose the right output for your workflow.
{"name":"Alice","age":32}
{"name":"Bob","age":28}
{"name":"Carol","age":29}
One JSON document per line. Default mongoimport format — streams efficiently for large files. Run with --type json.
[
{"name":"Alice","age":32},
{"name":"Bob","age":28},
{"name":"Carol","age":29}
]
Array of documents. Use with mongoimport --jsonArray. Works for APIs that expect a JSON array as the request body.
db.users.insertMany([
{"name":"Alice","age":32},
{"name":"Bob","age":28},
{"name":"Carol","age":29}
]);
Paste directly into mongosh, MongoDB Compass Shell or any MongoDB driver console. No external tools needed.
The native MongoDB CSV import command — no conversion needed for simple cases.
Loading reference data, seed records and initial dataset into a MongoDB collection during development or deployment. CSVShift converts the CSV to NDJSON and generates the mongoimport command — paste it into your terminal to seed the database in one step.
Atlas Data API and Atlas CLI both support NDJSON import. Converting CSV to NDJSON with CSVShift produces properly typed documents — numbers as integers, booleans as booleans — rather than the string-only output of direct CSV import.
Moving from a relational database (CSV export) to MongoDB requires converting flat tabular data to JSON documents. Dot-notation expansion (address.city → nested objects) lets you reshape the CSV into MongoDB's document model without writing transformation code.
Quickly loading a CSV dataset into MongoDB for API prototyping, testing queries or evaluating schema design. The insertMany() output can be pasted directly into MongoDB Compass's embedded shell without any command-line tools.
MongoDB import ready
in your browser. Zero upload.
CSVShift converts CSV to MongoDB-ready JSON entirely in JavaScript. Your data never touches a server. The type coercion maps CSV strings to proper JSON types — integers, floats, booleans and null — producing documents that match what you'd get from writing a pymongo import script, without writing any code.
The dot-notation expansion feature converts flat CSV headers like address.city into nested MongoDB documents — useful when your CSV was exported from a normalised schema and you want to re-nest it for MongoDB's document model.
mongoimport --db mydb --collection mycoll --type csv --headerline --file data.csv — all values imported as strings. 2) Convert to NDJSON first using CSVShift for type-aware import: mongoimport --db mydb --collection mycoll --type json --file data.json.{"age": 32} stores as a BSON integer, not the string "32". Queries like {"age": {"$gt": 30}} only work correctly on integer fields.mongoimport --uri "mongodb+srv://user:pass@cluster.mongodb.net/mydb" --collection mycoll --type json --file data.json. Or use MongoDB Compass — connect to Atlas, open the collection, click Add Data → Import File, select the NDJSON or JSON Array file from CSVShift.import csv, pymongo; client = pymongo.MongoClient('mongodb://localhost/'); docs = list(csv.DictReader(open('f.csv'))); client.mydb.mycoll.insert_many(docs). For type coercion, convert string values to int/float/bool before inserting. insert_many() is much faster than looping insert_one().