mongoexport Command Examples

Produce exports of data stored in a MongoDB instance formatted as JSON or CSV. More information: https://docs.mongodb.com/database-tools/mongoexport/.

mongoexport --uri={{connection_string}} --collection={{collection_name}}

mongoexport --db={{database_name}} --collection={{collection_name}} --query="{{query_object}}" --out={{path/to/file.json}}

mongoexport --collection={{collection_name}} --jsonArray

mongoexport --collection={{collection_name}} --type={{csv}} --fields="{{field1,field2,...}}" --out={{path/to/file.csv}}

mongoexport --collection={{collection_name}} --type={{csv}} --fields="{{field1,field2,...}}" --queryFile={{path/to/file}} --noHeaderLine --out={{path/to/file.csv}}

mongoexport --uri={{mongodb_uri}} --collection={{collection_name}} --pretty

mongoexport --help