Withdata Software

3 ways to export MongoDB data to files (CSV, TSV, JSON) without coding

Sometimes, you need to export MongoDB data to files, CSV, JSON, or other types, here are some tools you can use.

1. mongoexport

https://www.mongodb.com/docs/database-tools/mongoexport/

mongoexport is a command-line tool that produces a JSON or CSV export of data stored in a MongoDB instance.

MongoDB Export JSON

mongoexport –host=”mongodb0.example.com:27017″ –collection=events –db=reporting –out=events.json

MongoDB Export CSV

mongoexport –db=users –collection=contacts –type=csv –fieldFile=fields.txt –out=/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 MongoToFile

https://withdata.com/mongo-to-file/

MongoToFile is a data conversion software that helps you to export MongoDB database data to CSV (TXT), SQL, JSON, XML, html, and Excel. 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:

MongoDB Export database to CSV files

https://www.withdata.com/tools/mongodb-to-file/mongodb-to-csv

MongoDB Export database to JSON files

https://www.withdata.com/tools/mongodb-to-file/mongodb-to-json

more:
MongoDB export to TSV
MongoDB export to Excel
MongoDB export to XML
MongoDB export to SQL

MongoDB → JSON reference

Type mapping

Value kindin MongoDBin JSON
IntNumberInt / int321234 (number)
BigintNumberLong / int649007199254740993
DecimalDecimal1281234.56 (number)
FloatDouble1.234e10 (number)
TextString"text" (string)
Long textString"multi-line\ntext" (escaped newline inside a string)
DateISODate"2026-09-18" (string)
DatetimeISODate"2026-09-18T14:30:00Z" (string)
BinaryBinData"base64:..." (string)
BooleanBooltrue / false (boolean)
JSONEmbedded document or arraynested object or array, kept as structure

Dialect differences

MongoDB is a database server and JSON is a file format, so the gap is wider than a dialect difference - the rows below are where values and structure stop lining up.

Propertyin MongoDBin JSON
port27017—
identifiersNo identifier quoting - names are plain stringsDouble quotes; backslash escapes
row limit.limit(n) / $limit aggregation stage—
datesISODate() / BSON date (millisecond epoch internally)No date type: dates arrive as strings and the reader must p...
long textString (BSON string, no length limit)—
binaryBinData (BSON binary subtype)Not supported natively - base64 inside a string
separator—Braces and commas
encoding—UTF-8 by definition
typing—string, number, boolean, null, object, array - no date type
shapeCollections of documents with optional nestingNested objects and arrays
ceiling—Whole document is usually parsed into memory

Command line

SideCommand
MongoDBmongoexport --collection=c --out=f.json
MongoDB (load)mongoimport --collection=c --file=f.json

MongoToFile without the manual work

For batch jobs, large files and scheduling use the MongoToFile 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).