import mapper mapper_output = mapper.mapper(...) G = mapper_output.to_d3js_graph() import json with open('mapper.json', 'wb') as f: json.dump(G, f)