Docs Menu

Export Query to Specific Language

New in version 1.15.0

You can export queries created in the query bar to one of the supported languages; Java, Node, C#, and Python 3. This feature facilitates reformatting and utilizing queries created in MongoDB Compass for use in your application.

  1. After constructing a query in the query bar, click to the right of the Reset button.
  2. Select Export to Language:

    Query bar export dropdown menu
    click to enlarge
  3. In the Export Query To: dropdown, select your desired language:

    Query bar language select
    click to enlarge

    The My Query pane on the left displays your query in mongo shell syntax.

    The pane to the right displays your query in the language selected.

  4. (Optional): Check the Include Import Statements option to include the required import statements for the language selected.
  5. (Optional): Check the Include Driver Syntax option to include application code for the language selected. If you include driver syntax, the copyable code reflects project, sort, maxtimems, collation, skip and limit options.
  6. Click at the top-right of the formatted query to copy the query for the selected language to your clipboard. You can now easily integrate and execute your created query in your application.

    Copy button clicked in Export Query to Language modal
    click to enlarge
  7. Click Close to return to the Documents Tab.
Give Feedback
© 2021 MongoDB, Inc.


  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.