MongoDB Import, Export, and Database Tools/Export a collection to JSON

Write documents to a JSON file.

Section: Import and export data

Export a collection to JSON

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

Useful for interoperability, reporting, and selective migrations.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Import and export data
Export selected fields to CSV
Create a CSV export for spreadsheets or BI tools.
OpenIn sheetbashsame section
Import JSON data
Load JSON documents into a collection.
OpenIn sheetbashsame section
Import CSV data
Load CSV rows into a collection.
OpenIn sheetbashsame section
Convert BSON to JSON
Inspect dump data as JSON.
OpenIn sheetbashsame section
List GridFS files
Show files stored in GridFS.
Upload a file to GridFS
Store a local file in GridFS.