Sometimes, you need to import data from files, CSV, JSON, or other types, to MongoDB collections, here are some tools you can use. All supports Atlas.
1. mongoimport
https://www.mongodb.com/docs/database-tools/mongoimport/
mongoimport is a powerful command-line tool for importing data from JSON, CSV, and TSV files into MongoDB collections.
MongoDB Import JSON
mongoimport --host=mongodb1.example.net --port=37017 --username=user --collection=contacts --db=marketing --file=/opt/backups/mdb1-examplenet.json
MongoDB Import CSV,TSV
mongoimport --db=users --collection=contacts --type=csv --headerline --file=/opt/backups/contacts.csv
2. MongoDB Compass
https://www.mongodb.com/docs/compass/current/
MongoDB Compass is a powerful GUI for querying, aggregating, and analyzing your MongoDB data in a visual environment.
You can use MongoDB Compass to import and export data to and from collections. Compass supports import and export for both JSON and CSV files.
for details: https://www.mongodb.com/docs/compass/current/import-export/
3. WithData FileToMongo
https://withdata.com/file-to-mongo/
FileToMongo is a data conversion software that helps you to import File (TXT, CSV, TSV, EXCEL, JSON, XML, SQL, INI, RDF, LOG) data to MongoDB. Support all MongoDB deployment types: standalone, replica set, sharded cluster, and MongoDB Atlas.
Support Windows, Linux, and macOS.
Can run in GUI and CLI mode.
For details:
Import CSV file to MongoDB collection
https://www.withdata.com/tools/file-to-mongodb/csv-to-mongodb
Import JSON file to MongoDB collection
https://www.withdata.com/tools/file-to-mongodb/json-to-mongodb
more:
Import TSV to MongoDB
Import Excel to MongoDB
Import XML to MongoDB
Import SQL to MongoDB
CSV → MongoDB reference
Type mapping
| Value kind | in CSV | in MongoDB |
|---|---|---|
| Int | 1234 | NumberInt / int32 |
| Bigint | 9007199254740993 | NumberLong / int64 |
| Decimal | 1234.56 | Decimal128 |
| Float | 1.234e+10 | Double |
| Text | quoted only when it contains a comma or a quote | String |
| Long text | must be quoted; line breaks inside force multi-line records | String |
| Date | 2026-09-18 | ISODate |
| Datetime | 2026-09-18 14:30:00 | ISODate |
| Binary | not representable - base64 or hex string | BinData |
| Boolean | TRUE / FALSE, or 1 / 0 depending on the writer | Bool |
| JSON | the whole JSON value quoted, with internal quotes doubled | Embedded document or array |
Dialect differences
CSV is a file format and MongoDB is a database server, so the target has to be told the types the file never carried - the rows below are where the two sides diverge.
| Property | in CSV | in MongoDB |
|---|---|---|
| port | — | 27017 |
| identifiers | Double quotes; a literal quote is doubled ("" ) | No identifier quoting - names are plain strings |
| row limit | — | .limit(n) / $limit aggregation stage |
| dates | Conventional text: 2026-09-18 or 2026-09-18 14:30:00 | ISODate() / BSON date (millisecond epoch internally) |
| long text | — | String (BSON string, no length limit) |
| binary | Not supported | BinData (BSON binary subtype) |
| separator | Comma "," | — |
| encoding | No declaration - UTF-8 works only with a BOM | — |
| typing | None - every field is text | — |
| shape | Flat table, optional header row | Collections of documents with optional nesting |
| ceiling | No formal limit; row count bounded by memory | — |
Command line
| Side | Command |
|---|---|
| MongoDB | mongoexport --collection=c --out=f.json |
| MongoDB (load) | mongoimport --collection=c --file=f.json |
FileToMongo without the manual work
For batch jobs, large files and scheduling use the FileToMongo converter — an offline desktop app for Windows, Linux and macOS. Free trial.
New to the format? Read what a TSV file is (and how it differs from CSV).