Format beautify prettify JSON file
We need to import the inbuilt JSON module to format the JSON text data. We will use two functions json.load() and json.dumps()
json.load() is used to load the file or the string
json.dumps() is used to dump the formatted code, it returns the string that we can further write to the desired file or can be printed using print command on the standard output.
The Online Python code editor shows three tabs. The first tab contains the code. The second tab titled “json_input.txt” contains the sample unformatted data. Simply paste your JSON unformatted text into the json_input.txt and execute the python script and the formatted code will be shown in the third tab titled json_output.txt