Try the jsbeautifier library to decorate JavaScript. This works because JSON is an "almost" subset of JavaScript.
import json import jsbeautifier invalid_json = '{"hello": "world",}' json.loads(invalid_json) # ValueError: Expecting property name: line 4 column 1 (char 25) jsbeautifier.beautify(invalid_json) # '{\n "hello": "world",\n}'
source share