Docs Menu
Docs Home
MongoDB Shell


On this page

  • Learn More

MongoDB uses BSON, a binary serialization format, to store documents and to exchange data. BSON is a rich format and has data types that aren't included in the JSON standard. Extended JSON (EJSON) adds support for the additional types. EJSON is a JSON compatible way to represent BSON values.

mongosh exposes the EJSON interface from the Node.js BSON parser to help you transform your data. Use the EJSON interface when you need to transform BSON data.

EJSON Method
Convert Extended JSON objects to BSON objects. This method is useful to import JSON data from external applications.
Convert BSON objects to strings. This method is useful to transform mongosh output.
Convert BSON objects to Extended JSON representation as JavaScript objects. This method is useful to export JSON data for external data transformation applications.
Convert strings to JSON. This method is useful to transform inputs.

For additional EJSON capabilities, see the npm EJSON documentation.

BSON specification

← Methods

On this page