MongoDB Import, Export, and Database Tools

Use mongoimport, mongoexport, bsondump, and GridFS tools for practical MongoDB data movement workflows.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Import and export data

Command-line tools for structured data movement.

Export a collection to JSON

Write documents to a JSON file.

bashANYmongoexportjsonmongodb
bash
mongoexport --uri="mongodb://localhost:27017/appdb" --collection=users --out=users.json

Useful for interoperability, reporting, and selective migrations.

Export selected fields to CSV

Create a CSV export for spreadsheets or BI tools.

bashANYmongoexportcsvmongodb
bash
mongoexport --uri="mongodb://localhost:27017/appdb" --collection=users --type=csv --fields=name,email,created_at --out=users.csv

CSV export is handy when downstream tools expect a flat tabular format.

Import JSON data

Load JSON documents into a collection.

bashANYmongoimportjsonmongodb
bash
mongoimport --uri="mongodb://localhost:27017/appdb" --collection=users --file=users.json --jsonArray

`--jsonArray` is required when the source file contains one top-level JSON array.

Import CSV data

Load CSV rows into a collection.

bashANYmongoimportcsvmongodb
bash
mongoimport --uri="mongodb://localhost:27017/appdb" --collection=users --type=csv --headerline --file=users.csv

`--headerline` uses the first row as field names.

Convert BSON to JSON

Inspect dump data as JSON.

bashANYbsondumpbsonjson
bash
bsondump dump/appdb/users.bson > users.json

Useful when you want to inspect BSON dump content in a human-readable format.

GridFS and files

Work with files stored in MongoDB GridFS.

List GridFS files

Show files stored in GridFS.

bashANYmongofilesgridfsfiles
bash
mongofiles --uri="mongodb://localhost:27017/appdb" list

Useful when MongoDB is being used to store large files or media via GridFS.

Upload a file to GridFS

Store a local file in GridFS.

bashANYmongofilesgridfsupload
bash
mongofiles --uri="mongodb://localhost:27017/appdb" put report.pdf

Uploads the file into GridFS collections.

Download a GridFS file

Retrieve a file from GridFS.

bashANYmongofilesgridfsdownload
bash
mongofiles --uri="mongodb://localhost:27017/appdb" get report.pdf

Good for round-trip validation and recovery tasks.

Recommended next

No recommendations yet.