import os import json json_files = []; for file in os.listdir(): if file.endswith('.json'): json_files.append(file) result = list() for f1 in json_files: with open(f1, 'r') as infile: result.extend(json.load(infile)) with open('join_dataset.json', 'w') as output_file: json.dump(result, output_file)