Free CSV to MongoDB — mongoimport ready — no upload

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.

Your data never leaves your browser
mongoimport command generated
NDJSON / Array / insertMany
MongoDB Atlas compatible
Always free
CSV to MongoDB  100% client-side
Drop your CSV file here
.csv, .txt or .tsv — or paste below
or paste CSV directly
mongoimport command
 Import ready

      
Three MongoDB import formats

Choose the right output for your workflow.

NDJSON (recommended)
{"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.

JSON Array
[
  {"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.

insertMany()
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.

Import CSV directly with mongoimport

The native MongoDB CSV import command — no conversion needed for simple cases.

mongoimport — CSV mode (simplest)
mongoimport \ --db mydb \ --collection mycoll \ --type csv \ --headerline \ --file data.csv # MongoDB Atlas connection: mongoimport \ --uri "mongodb+srv://user:pass@cluster.mongodb.net/mydb" \ --collection mycoll \ --type csv \ --headerline \ --file data.csv
--headerline uses the first row as field names. All values imported as strings — use CSVShift's NDJSON output for proper type coercion (integers, booleans, nulls).
mongoimport — NDJSON mode (type-aware)
# Convert CSV to NDJSON with CSVShift first, then: mongoimport \ --db mydb \ --collection mycoll \ --type json \ --file data.json # With upsert (update existing by _id): mongoimport \ --db mydb \ --collection mycoll \ --type json \ --file data.json \ --mode upsert \ --upsertFields name,email
NDJSON preserves number, boolean and null types — unlike CSV mode which imports everything as strings. --mode upsert prevents duplicate documents on re-import.
Python — pymongo direct insert
import csv, pymongo client = pymongo.MongoClient("mongodb://localhost:27017/") db = client["mydb"] coll = db["mycoll"] with open("data.csv", newline="") as f: reader = csv.DictReader(f) docs = [] for row in reader: # Type coercion: doc = {} for k, v in row.items(): try: doc[k] = int(v) except ValueError: try: doc[k] = float(v) except ValueError: doc[k] = v if v else None docs.append(doc) result = coll.insert_many(docs) print(f"Inserted {len(result.inserted_ids)} documents")
Requires: pip install pymongo. insert_many() is significantly faster than individual insert_one() calls — batches the insert in a single network round-trip.
When do you need CSV to MongoDB?
Initial data seeding

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.

MongoDB Atlas import

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.

Data migration

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.

Testing and prototyping

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.

Related CSV tools
Popular searches
csv to mongodb import csv to mongodb how to import csv into mongodb mongoimport csv csv to mongodb converter import csv file mongodb atlas csv to mongodb python csv to mongodb atlas mongodb import csv file csv to bson mongodb convert csv to mongodb json mongoimport csv type

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 command generated
The correct mongoimport command for your collection and format is generated automatically — copy and run.
Type-aware NDJSON
Numbers, booleans and nulls in CSV become proper JSON types — not strings. mongoimport CSV mode can't do this.
Dot-notation nesting
Headers like address.city expand to nested documents matching MongoDB's document model.
Free, no conditions
No row limit, no watermark, no account. Funded by display advertising only.
Frequently asked questions
How do I import a CSV file into MongoDB?
Two methods: 1) Direct CSV import: 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.
What is NDJSON and why use it instead of CSV import?
NDJSON (Newline Delimited JSON) has one JSON document per line. Unlike mongoimport's CSV mode — which imports all values as strings — NDJSON preserves types: {"age": 32} stores as a BSON integer, not the string "32". Queries like {"age": {"$gt": 30}} only work correctly on integer fields.
How do I import CSV into MongoDB Atlas?
Use mongoimport with an Atlas connection string: 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.
How do I convert CSV to MongoDB in Python?
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().
Is my data safe when converting CSV to MongoDB format online?
Yes. CSVShift generates the NDJSON/JSON output entirely in your browser. Your CSV is never uploaded to any server. Open the Network inspector during conversion — zero outbound data requests are made.