import json from pymongo import MongoClient myclient = MongoClient("mongodb://localhost:8888/") db = myclient("") Collection = db["restaurants"] with open('restaurants.json') as file: file_data = json.load(file) if isinstance(file_data, list): collection.insert_many(file_data) else: collection.insert_one(file_data) with open('restaurants.json','r') as file: data = json.load(file) print data