Is there any way to export mongo collection into a json format with the node.js driver using fs.writeFile
No. The driver doesn't come with pre-written functions for doing this. You can do it yourself by writing out the documents as you iterate over them with a cursor. You could even parallelize the operation by dividing up the work based on ranges of some indexed field. There's an executable, mongoexport, that exports the contents of a database as JSON. Be mindful that exporting as JSON can lose type information. If you want to preserve all of the type information, like if you want to make a copy of part of the database to seed another instance, use mongodump instead (which dumps BSON, not JSON).