Withdata Software

3 ways to import data from files (CSV, TSV, JSON) into MongoDB without coding

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 kindin CSVin MongoDB
Int1234NumberInt / int32
Bigint9007199254740993NumberLong / int64
Decimal1234.56Decimal128
Float1.234e+10Double
Textquoted only when it contains a comma or a quoteString
Long textmust be quoted; line breaks inside force multi-line recordsString
Date2026-09-18ISODate
Datetime2026-09-18 14:30:00ISODate
Binarynot representable - base64 or hex stringBinData
BooleanTRUE / FALSE, or 1 / 0 depending on the writerBool
JSONthe whole JSON value quoted, with internal quotes doubledEmbedded 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.

Propertyin CSVin MongoDB
port—27017
identifiersDouble quotes; a literal quote is doubled ("" )No identifier quoting - names are plain strings
row limit—.limit(n) / $limit aggregation stage
datesConventional text: 2026-09-18 or 2026-09-18 14:30:00ISODate() / BSON date (millisecond epoch internally)
long text—String (BSON string, no length limit)
binaryNot supportedBinData (BSON binary subtype)
separatorComma ","—
encodingNo declaration - UTF-8 works only with a BOM—
typingNone - every field is text—
shapeFlat table, optional header rowCollections of documents with optional nesting
ceilingNo formal limit; row count bounded by memory—

Command line

SideCommand
MongoDBmongoexport --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).