Docs Home / Compass / Create an Aggregation Pipeline

Export Aggregation Pipeline Results

To use your aggregated data in other external tools, you can export your pipeline results from MongoDB Compass as a JSON or CSV file.

About this Task

Avoid using CSV files exports to back up your data. CSV files may lose type information and are not suitable for backing up your data.

Steps

1

Click Export

In the top right of the aggregation pipeline builder, click the Export button to open the modal.

undefinedExport button on aggregation pipeline
2

Choose the file type for your export

Under Export File Type, select either JSON or CSV. If you select JSON, your data is exported to the target file as an array of JSON objects.

3

(Optional) Choose an advanced JSON format option

If choose to export your data as a JSON file, you can expand the Advanced JSON Format drop-down menu and select from the following extended JSON formats:

JSON FormatDescriptionSample Document
Default Extended JSONA string format that avoids any loss of BSON type information. This is the default Compass setting.
{
"fortyTwo" : 42,
"oneHalf" : 0.5,
"bignumber" : {
"$numberLong" : "5000000000"
}
}
Relaxed Extended JSON

A string format that emphasizes readability and interoperability at the expense of type preservation. That is, conversion from relaxed format to BSON can lose type information.

WARNING: This format is not recommended for data integrity.

{
"fortyTwo" : 42,
"oneHalf": 0.5,
"bignumber" : 5000000000
}
Canonical Extended JSONA string format that emphasizes type preservation at the expense of readability and interoperability. That is, conversion from canonical to BSON will generally preserve type information except in certain specific cases.
{
"fortyTwo" : {
"$numberInt" : "42"
},
"oneHalf" : {
"$numberDouble" : "0.5"
},
"bignumber" : {
"$numberLong" : "5000000000"
}
}
4

Click Export

5

Specify export destination

In the new pop-up modal, enter a name for your export file, specify the file destination, and click Select to export your pipeline results.

Learn More