Try Studio 3T for Free

Export Wizard

With Studio 3T’s Export Wizard, you can export MongoDB collections, views, queries, query results, or specific documents to CSV, JSON, BSON/mongodump, SQL, or another collection.

Download the Export Wizard here and jump ahead to the relevant chapter:

Looking to import, not export? Use the Import Wizard instead to import data from CSV, JSON, BSON/mongodump, SQL, and another collection to MongoDB.

Open the Export Wizard

Once connected to a MongoDB database, open the Export Wizard by clicking on Export in the Global Toolbar.

Click on Export in the global toolbar

Alternatively, you can right-click on any server, database, or collection in the Connection Tree and choose Export (Collections, Buckets, Views).

Export collection from the Connection Tree

Or right-click anywhere on a Result tab (Collection Tab, SQL Query, IntelliShell), or any input or output panel in Aggregation Editor and choose Export.

Export MongoDB documents directly from the Results tab

Export sources

With Studio 3T, you can export the following throughout the application:

Studio 3T-supported export sources

  • Entire collections
  • Entire views
  • The current query result of a find() or aggregation query
  • The current cursor
  • Specific documents

 

 

For all exports, you can choose one of six actions from the toolbar:

The Export Wizard toolbar

  • Save the export as a task, which you can execute on-demand or schedule for later
  • Execute the task immediately
  • Add, edit or remove export units

Change the export source

While configuring your export, you can also change the export source (e.g. connection, database, collection) at any time.

Under Export source in the Export unit tab, you can:

  • Click to change the source from your list of databases or connections
  • Drag the source from the Connection Tree directly into the tab

Change databases, connections, and connections by dragging directly from the Connection Tree

If you’re exporting find() query results, you can edit them directly in the Query bar of any Export unit tab.

The Query bar also validates your JSON as you type.

Edit find queries on the go during export

Change the export file path

You can also configure the default target folder in the Export Overview tab. Studio 3T will remember any changes to this path.

Configure the default target folder path under global options

Export MongoDB to CSV (e.g. Excel)

Open the Export Wizard and select your export source.

This screen only appears if you haven’t chosen an item in the Connection Tree, run a previous query, or selected specific documents.

Choose export source

Next, choose CSV as the export format then click Next.

Choose CSV as export format

Studio 3T performs a partial scan of 100 documents to automatically detect fields within your collection.

To detect all fields, you can click on Full scan – which might take some time – or manually add the missing fields by clicking on Add custom field.

Choose which fields to export to CSV, or add custom fields

Click Finish. This will open the Export overview tab and display the Export unit #1 – CSV tab by default.

The Export unit – CSV tab has six sections.

CSV configuration options in Studio 3T

  1. Export source – Displays the source connection, database, and collection. You can change this by clicking within the blue dotted box, or by dragging the source from the Connection Tree directly into the tab.
  2. Select fields – Add or remove custom fields and check or uncheck fields to be included in the export.
  3. Select target – Choose between clipboard or file, and define the file path as needed.More CSV configuration options in Studio 3T
  4. CSV format – Configure settings like preset, delimit, record separator, etc.
  5. Other options – Configure non-formatting settings like how to treat null values, column headers, etc.
  6. Output preview – Click on the arrow button to expand the preview of the CSV file.

 

To configure global export options, go to the Export overview tab.

Configure global options in the Export Overview tab

After configuring the export, you can run the export immediately by clicking on Execute in the toolbar.

Click on Execute to run the export

You can also run multiple CSV exports at once by adding more export units.

To save time, you can save your CSV export as a task, which you can then schedule to run later.

To track your export’s progress, check the Operations window on the bottom-left hand corner.

From here you can also directly view the export file. Right-click on an export in the same window and choose Open in File Explorer (Windows, Linux) or Reveal in Finder (macOS).

Get to your exported file directly from the Operations window

Ready to export? Download the latest Studio 3T version here.

Export MongoDB to JSON

Open the Export Wizard and choose your export source.

This screen below will appear if you haven’t chosen an item in the Connection Tree, run a previous query, or selected specific documents.

Choose export source

In this example, we will export the current query result of the find() query { "package": "Premium" }, which we built using Visual Query Builder.

Export current query results

Export options in Studio 3T

Next, select JSON as the export format and click Next.

Choose JSON as the export format

Click Finish. This will open the Export overview tab and display the Export unit #1 – JSON tab by default.

The Export unit – JSON tab has five sections.

Five sections of the JSON export unit tab

  1. Export source – Displays the source connection, database, and collection. Make sure that the source is correct. In this example, we are exporting the current query result of the find() query { "package": "Premium" }. You don’t need to go back to the original query to edit it – you can do so edit directly in the Query bar.
  2. Format options – Choose between JSON mongo shell/Studio 3T or JSON mongoexport.

    What’s the difference between the two JSON format options?

    JSON mongo shell/Studio 3T exports a collection to a rich, type-conserving collection.json file, in the JSON format used in the mongo shell, which makes for an easy paste job.JSON mongoexport produces a JSON format that the mongoexport tool generates.

  3. Select target – Select between clipboard or file, and define the file path as needed.
  4. Other options – Choose to export with commas between documents, or export as document array.
  5. Output preview – Click on the arrow to display the JSON preview, which dynamically updates as you configure the export settings.

Switch to the Export overview tab to configure global export options.

Configure global options in the Export Overview tab

Once your unit is export-ready, click on Execute to run the export immediately.

Click on Execute to run the export

Alternatively, run multiple JSON exports at once by adding more export units, or save the JSON export as a task, which you can then schedule to run later.

You can track your JSON export’s progress in the Operations window, on the bottom-left hand corner.

Get to your exported file directly from the Operations window

To view the export file, right-click on an export in the same window and choose Open in File Explorer (Windows, Linux) or Reveal in Finder (macOS).

Download Studio 3T to start your JSON export.

Export MongoDB to SQL

Moving data from collections to tables? MongoDB to SQL Migration lets you export MongoDB collections directly to a SQL database or file and configure MongoDB to SQL mappings before export.

Open the Export Wizard and choose SQL as the export format. Click Next.

Choose SQL as the export format

Choose one of the supported SQL databases: MySQL Server, Microsoft SQL Server, PostgreSQL, and Oracle Database.

Supported SQL databases

Then, select the fields to include in the SQL export.

Studio 3T partially scans the first 100 documents in the collection to detect fields and map source types to SQL column types.

Select the fields to include in the export to SQL

To detect all fields, click on Full scan or manually add the missing fields by clicking on Add custom field.

To override the auto-detected SQL column names and SQL column types, double-click on a cell and edit the value.

Click Finish. The Export overview and Export unit #1 – SQL tabs will open.

The Export unit – SQL tab, where you can further edit the export, has seven sections.

Select the fields to include in the export to SQL

  1. Export source – Displays the source.
  2. SQL format – Displays the target SQL format.
  3. Select fields – Here you can add or remove custom fields, move fields up or down, check or uncheck, and edit SQL field names and types.More configuration options
  4. Select target – Select between clipboard or file, and define the file path as needed.
  5. SQL table name – Enter the SQL table name.
  6. Other options – Configure other settings like adding “CREATE TABLE” and “DROP TABLE IF EXISTS” statements.
  7. Output preview – Click on the arrow to show a preview of the SQL file.

 

 

Configure other global settings as needed in the Export overview tab.

Once you’re done setting up the export, you can run the export immediately by clicking on Execute in the toolbar.

Click on Execute to run the export

Alternatively, add more export units so that you can run multiple SQL exports in one go, or save the SQL export as a task that you can run on-demand or schedule for later.

Export MongoDB to SQL is a feature available in Studio 3T Pro and Enterprise. Studio 3T supports all the major SQL databases: Oracle, Microsoft SQL Server, MySQL, and PostgreSQL.

Export MongoDB to BSON or mongodump

Open the Export Wizard.

You will see the screen below if you haven’t chosen an item in the Connection Tree, run a previous query, or selected specific documents.

Choose export source

Choose mongodump as the export format and click Finish.

This will open the Export overview tab and display the Export unit #1 – mongodump tab by default.

The Export unit – mongodump tab has four sections.

mongodump export options

  1. Export source – Shows the export source connection, database, and collection. You can change this by clicking within the blue dotted box, or by dragging the source from the Connection Tree directly into the tab.
  2. Format options – Choose between BSON – mongodump folder or BSON – mongodump archive.
  3. Select the destination folder – Define the folder path as needed.
  4. Other options – Configure other settings like compression, document recovery, etc.

Switch to the Export overview tab to configure global export options.

Once your unit is export-ready, you can run the export immediately by clicking on Execute.

Click on Execute to run the export

To run multiple exports in one job, you can also add export units, or save the BSON export as a task that you can schedule to run later.

Export to another collection

Want a faster solution? Copy and paste MongoDB collections between databases instead.

Open the Export Wizard.

If you haven’t chosen an item in the Connection Tree, run a previous query, or selected specific documents, you will be prompted to choose an export source.

Choose export source

Once you’ve made a selection, choose To another collection the click Next.

Export to another collection

Click on Click here to connect to a server to select a target connection. This will open open the Connection Manager.

Choose the target connection

Choose the target server and click Connect. Then, choose the collection and click Finish.

This will open the Export overview tab and display the Export unit #1 – Another collection tab by default.

The Export unit – Another collection tab has three sections.

Configuration options when exporting to another collection

  1. Export source – Displays the export source connection, database, and collection. You can change this by clicking within the blue dotted box, or by dragging the source from the Connection Tree directly into the tab.
  2. Export target – Shows the export target connection/database/collection. You can edit this by clicking within the blue dotted box, or by dragging the source from the Connection Tree directly into the tab.
  3. Export mode – Choose one from the six export modes.

Go to the Export overview tab to configure global export options.

After you’ve configured your export, you can run the export immediately by clicking on Execute in the toolbar.

Click on Execute to run the export

Alternatively, add more export units so that you can run multiple exports at once, or save the export as a task that you can run on-demand or schedule for later.

Automate & schedule exports as tasks

Export Wizard integrates with two other features – Tasks and Task Scheduler – so that you can save frequently-run exports as tasks.

Click on Save task (as) to save an export as a task.

Name the task, then click OK.

Save MongoDB exports as tasks

This saves the task in the Task Viewer, from which you can choose to schedule, unschedule, edit, clone, delete, add, and execute tasks.

Learn more about Tasks and Tasks Scheduler.

Export multiple or all MongoDB collections at once

The Export Wizard treats each export as an export unit.

Instead of having to run single exports one after another, you can add multiple export units that you can run at once, which is a huge time-saver in tandem with Tasks and Tasks Scheduler.

Add export units

Set up your first export unit using your format of choice:

The quickest way to add new export units is to drag items directly from the Connection Tree into the Export units section (in this case, the expats collection).

Drag new export units directly from the Connection Tree

Alternatively, choose Add unit from the toolbar.

Click on Add Unit in the Export Wizard toolbar

This will prompt you to choose your new unit’s export source. Here we’ll choose Connection tree item.

Choose the new unit's export source

Note that the Find query and Aggregation query options will only work if results have been copied to the clipboard.

Click on Click here to connect to a server. This will open the Connection Manager. Choose the target server, then click Connect.

Choose your source connection

Next, chose the connection tree items (databases, collections, views) to export. You can choose multiple items at once. Click Next.

Choose the connection tree items to export

Then, choose the export format.

Configure the new export unit as you would any export. Each export will open in a separate Export unit tab.

Each MongoDB export opens in a separate Export unit tab

Under the Export overview tab, you can find an overview of all export units bundled in your job.

Run multiple exports at once

Edit export units

Click on Edit unit in the toolbar.

Edit export units

From the Export overview tab, you can also double-click on the export unit, or right-click on the unit and choose Edit selected units.

Remove export units

Click on Remove unit in the toolbar.

Remove export units

Alternatively from the Export overview tab, select the unit to be removed and either click on Remove unit in the toolbar or right-click and choose Remove selected items.

Trigger export sources and formats

At first glance, you might wonder why you don’t see all available export sources options.

The prompt you see will depend on which item(s) you’re trying to export or where you’ve clicked in the application.

If no item is selected, clicking on Export in the global toolbar will prompt you to choose the export source.

Prompt when no item is chosen

When you choose items from the Connection Tree and click on Export, it will ask you to choose the export format directly.

Note that depending on the items chosen, only the applicable formats will be highlighted.

Export Wizard will highlight the relevant formats depending on what you've selected

When you click on Export from a Result tab (Collection Tab, IntelliShell, SQL Query), or an input or output panel in Aggregation Editor, it will skip the previous prompt and ask you directly which items you want to export.

Export options in Studio 3T

Current query result vs. current cursor – what’s the difference?

Exporting the current query result means that Studio 3T will always run the query before the export. You will always get the latest results and can keep working with them, but means that it might take longer. This option is compatible with mongodump.

Exporting the current cursor is faster, but it only exports the current results. If you need to work with the results after the export, you will need to re-run the query and re-export any new results. This option is not compatible with mongodump.

After you’ve selected an export source and export format, the export is considered as one (export) unit.

The Export Wizard lets you add multiple units – or multiple exports – to one job, so you can run multiple exports at once.

You can always find an overview of all export units in the Export overview tab, where you can configure global options, and add, edit, and remove units as needed.

Run multiple exports at once


Check out other time-saving Studio 3T features:

Updated on October 16, 2020

Was this article helpful?

Related Articles