import json with open('z.B._pr3_skriptspr_team12_s2\input.txt', 'r') as infile, open('z.B._pr3_skriptspr_team12_s2\personen.json', 'w') as outfile: for line in infile: json.dump(line, outfile, indent = 2, ensure_ascii=False)