Importing the data from Postman to MongoDB Atlas


I want to import the data from Postman like collections that I made there. But I don’t want to use Compass for importing.

What is the best way to import the Postman Data Collections and Environment from Postman to Mongodb Atlas, so that I donot néed to do that manually again?

I was trying to do with the DATA API in Atlas but I think this is not the right way to that as it is most used for managing the Mongodb collections from Mongodb to Postman. But in my case I need the opposite way i.e. my built in colections from Postman to database (ATLAS).

please correct me of I am wrong.


Postman collections and environments are just JSON files, right? You could just load them up into mongosh, JSON parse them and insert all of it or the portion you want with an insertOne/insertMany. Do you want to insert one document for the entire Postman collection or do you only want to insert the item in the Postman collection into MongoDB?

Either way, something like this should work

const collection = fs.readFileSync('/path/to/postman/collection.json', 'utf8');
const parsedCollection = JSON.parse(collection);

//switch to `postman` database

//insert all as one document

//insert all the items in the collection as separate documents

1 Like

Thanks a lot. I will try through this way :slight_smile: