mongoexport --db appdb --collection users --type=csv --fields=email,name --out users.csv

Category: Databases & SQL

mongoexport --db appdb --collection users --type=csv --fields=email,name --out users.csv

Export a collection to CSV

Exports only the email and name fields as CSV; --fields names the columns and must be supplied for CSV output. Rows with missing fields get empty values. Handy for spreadsheet workflows.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.