mongoexport --db appdb --collection users --out users.json

Category: Databases & SQL

mongoexport --db appdb --collection users --out users.json

Export a collection to JSON

Writes the users collection as newline-delimited JSON, ideal for moving data into other systems or archives. mongoexport is part of the database-tools package, separate from mongosh. Import the file back with mongoimport.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.