Showing results for pretty print json
Search instead for prettyprint json

Use the indent= parameter of json.dump() or json.dumps() to specify how many spaces to indent by:

>>> import json
>>> your_json = '["foo", {"bar": ["baz", null, 1.0, 2]}]'
>>> parsed = json.loads(your_json)
>>> print(json.dumps(parsed, indent=4))
[
    "foo",
    {
        "bar": [
            "baz",
            null,
            1.0,
            2
        ]
    }
]

To parse a file, use json.load():

with open('filename.txt', 'r') as handle:
    parsed = json.load(handle)
Answer from Blender on Stack Overflow
๐ŸŒ
JSONLint
jsonlint.com โ€บ json-pretty-print
JSON Pretty Print - Format & Beautify JSON Online | JSONLint | JSONLint
Pretty print JSON instantly with our free online formatter. Customize indentation, sort keys, and beautify minified JSON. No signup required.
๐ŸŒ
JSON Formatter
jsonformatter.org โ€บ json-pretty-print
Best JSON Pretty Print Online
JSON Pretty Print is very unique tool for prettify json and pretty print JSON data in color.
Discussions

Json, c#, pretty printing?
Alternatively, if you are using Newtonsoft, you can call JsonConvert.SerializeObject(object, formatting) passing Formatting.Indented as the second param to pretty print https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonConvert_SerializeObject_1.htm https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Formatting.htm Edit to answer your other question. Using Newtonsoft, you don't have to create a class to parse the JSON file. You can use JObect.Parse(object), but you and your tests will be much happier if you create a class and use JsonConvert.DeserializeObject(json) https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Linq_JObject.htm https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonConvert_DeserializeObject__1.htm I haven't looked in a while, but there might be a tool such that does what xsd.exe did to XML files and schemas for JSON. More on reddit.com
๐ŸŒ r/dotnet
13
2
June 18, 2020
Pretty print JSON from URL
I've not done a lot in this space but something I have tried in the past with JSON's is to convert to a pandas DataFrame. I'm not sure if this is exactly what you are after, but the following stackoverflow post may help: https://stackoverflow.com/questions/21104592/json-to-pandas-dataframe More on reddit.com
๐ŸŒ r/learnpython
13
2
August 27, 2021
how to have my view output pretty printed json
If you view the source code of the http response, it's pretty printed. If you want to see it the same way in the browser, you have to set the response mime type to application/json Edit: use content_type in the http response constructor https://docs.djangoproject.com/en/1.7/ref/request-response/#id3 More on reddit.com
๐ŸŒ r/django
7
5
February 5, 2015
Top answer
1 of 15
3105

Use the indent= parameter of json.dump() or json.dumps() to specify how many spaces to indent by:

>>> import json
>>> your_json = '["foo", {"bar": ["baz", null, 1.0, 2]}]'
>>> parsed = json.loads(your_json)
>>> print(json.dumps(parsed, indent=4))
[
    "foo",
    {
        "bar": [
            "baz",
            null,
            1.0,
            2
        ]
    }
]

To parse a file, use json.load():

with open('filename.txt', 'r') as handle:
    parsed = json.load(handle)
2 of 15
501

You can do this on the command line:

python3 -m json.tool some.json

(as already mentioned in the commentaries to the question, thanks to @Kai Petzke for the python3 suggestion).

Actually python is not my favourite tool as far as json processing on the command line is concerned. For simple pretty printing is ok, but if you want to manipulate the json it can become overcomplicated. You'd soon need to write a separate script-file, you could end up with maps whose keys are u"some-key" (python unicode), which makes selecting fields more difficult and doesn't really go in the direction of pretty-printing.

You can also use jq:

jq . some.json

and you get colors as a bonus (and way easier extendability).

Addendum: There is some confusion in the comments about using jq to process large JSON files on the one hand, and having a very large jq program on the other. For pretty-printing a file consisting of a single large JSON entity, the practical limitation is RAM. For pretty-printing a 2GB file consisting of a single array of real-world data, the "maximum resident set size" required for pretty-printing was 5GB (whether using jq 1.5 or 1.6). Note also that jq can be used from within python after pip install jq.

๐ŸŒ
npm
npmjs.com โ€บ package โ€บ pretty-print-json
pretty-print-json - npm
May 25, 2026 - Pretty-print JSON data into HTML to indent and colorize (written in functional TypeScript). Latest version: 3.0.8, last published: 2 months ago. Start using pretty-print-json in your project by running `npm i pretty-print-json`. There are 15 ...
      ยป npm install pretty-print-json
    
Published ย  May 25, 2026
Version ย  3.0.8
๐ŸŒ
LornaJane
lornajane.net โ€บ posts โ€บ 2024 โ€บ pretty-print-json-with-jq
Pretty-print JSON with jq | LornaJane
If we stopped at this point, weโ€™d get pretty, human-readable JSON content to look at with colour highlights in the terminal. I use this mode a lot when Iโ€™m debugging APIs. But in this case, I wanted the cute output in a file. > sends the output of stdout to a destination that isnโ€™t the terminal, and in this case I made it a file better.json.
Find elsewhere
๐ŸŒ
JSON Formatter
jsonformatter.curiousconcept.com
JSON Formatter & Validator
The JSON Formatter & Validator beautifies and debugs JSON data with advanced formatting and validation algorithms.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-pretty-print-json
Python - Pretty Print JSON - GeeksforGeeks
July 23, 2025 - The code takes a JSON string containing student records, parses it into a Python data structure, then pretty-prints the JSON data with proper indentation for improved readability.
๐ŸŒ
Zerodevx
zerodevx.github.io โ€บ json-pretty-print
JSON Pretty Print Online
Convert unformatted JSON into pretty-printed JSON and send the view as a shareable web link.
๐ŸŒ
YouTube
youtube.com โ€บ automate with rakesh
Python Pretty Print JSON String: Enhance Readability with Proper Formatting of JSON - YouTube
Learn the art of enhancing your JSON data's readability using Python's pretty print technique. In this tutorial, discover how to transform complex JSON strin...
Published ย  August 19, 2023
Views ย  2K
๐ŸŒ
Reddit
reddit.com โ€บ r/dotnet โ€บ json, c#, pretty printing?
r/dotnet on Reddit: Json, c#, pretty printing?
June 18, 2020 -

Hey peeps, I have seen a few ways to work with json output and was curious what is the โ€œbestโ€ or most effective way to take in and use json. It seems silly to have to make a class to parse json data, but if thatโ€™s the best way then fine, I can do that. The next thing is what might be the best way to display the json output? Python has something called pretty printing that tabs the data out in a clean format, I have also seen a text tree. Thanks in advance :)

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ pretty-print-json-in-python
Pretty Print JSON in Python - GeeksforGeeks
July 12, 2025 - # Write Python3 code here import json json_data = '[{"Employee ID":1,"Name":"Abhishek","Designation":"Software Engineer"},' \ '{"Employee ID":2,"Name":"Garima","Designation":"Email Marketing Specialist"}]' json_object = json.loads(json_data) # Indent keyword while dumping the # data decides to what level # spaces the user wants. print(json.dumps(json_object, indent = 1)) # Difference in the spaces # near the brackets can be seen print(json.dumps(json_object, indent = 3)) ... [ { "Employee ID": 1, "Name": "Abhishek", "Designation": "Software Engineer" }, { "Employee ID": 2, "Name": "Garima", "Designation": "Email Marketing Specialist" } ] [ { "Employee ID": 1, "Name": "Abhishek", "Designation": "Software Engineer" }, { "Employee ID": 2, "Name": "Garima", "Designation": "Email Marketing Specialist" } ] ... Example 2: Let's suppose we want to pretty-print the data from the JSON file.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ pretty print json from url
r/learnpython on Reddit: Pretty print JSON from URL
August 27, 2021 -

Hello Everyone,

I've hit a frustrating wall and after much googling I took a deep breath and felt the best approach was to ask you all for advice.

I'm making a very simple script and need assistance with what tool I should use to move forward.

Step 1: Fetch the URL Step 2: Make the JSON pretty. Such as a top-down listing of Title and URL only.

import requests

#make the URL call
page = requests.get('http://gleamlist.com:5000/api')
#verify the page has content - just for testing.
print(page.content)

I've tried using the json module but confuse myself and I've thought maybe BS4 would help but also confuse myself. I believe JSON is basically a dictionary and I want to parse out the info. Could anyone assist me with some tips or a specific topic to research and implement please?

Top answer
1 of 2
1

Try this:

  1. Open the Chrome DevTools (Ctrl+Shift+I).
  2. Navigate to the Overrides section in the Sources tab.
  3. Select the folder to save overrides (Chrome will request permissions for that).
  4. In the Network tab, go to the JSON file.
  5. Right-click the JSON response and select Save for overrides.
  6. Edit the saved JSON file somehow for the expected formatting.
  7. Refresh the page, and Chrome should load the locally formatted version.

As an alternative approach Use tools like mitmproxy or Charles Proxy to intercept JSON responses. Configure the proxy to modify JSON responses and then route Chrome/Brave traffic through the proxy.

2 of 2
0

How can I change a browser setting to make the "Pretty-print" checkbox checked by default without installing extensions?

You may change your web browser and luckily find another browser which has that setting enabled by default. Alternatively you may use some open source browser like Mozilla Firefox and change the default settings as you wish.

Why would anyone not want Pretty-print enabled?

JSON is not a format for human beings, but primarily for machines.

There is still chance that you (as a human) need to parse some JSON response, may be to debug a server-side script code or any other reason, but that chance is little.

The main use case for a human to use a web browser to get a JSON response, is to save it as a file and pipe it into another application or process.

Here the file size matters the most and thus it is not pretty-printed by default. Keep in mind that a JSON file may have thousands of entries and does not always have only multiple entries.

Why wouldn't it at least be enabled by default?

As said, because the file size matters the most and JSON response may have thousands of entries.

Update

Also, processing and rendering large JSON data in a pretty-printed format may take additional time and impact browser performance in some cases.

๐ŸŒ
Chrome Web Store
chromewebstore.google.com โ€บ detail โ€บ json-pretty โ€บ nflbalmkceonkkhifbifebanhladdgcp
JSON Pretty - Chrome Web Store
Use JSON Pretty to parse, format, and pretty print json data. A powerful json formatter and beautify tool for easy data readability.
๐ŸŒ
Js
pretty-print-json.js.org
Pretty Print JSON
Pretty-Print JSON -- Interactive online JavaScript tool to format JSON
๐ŸŒ
GitHub
github.com โ€บ Ortus-Solutions โ€บ JSONPrettyPrint
GitHub - Ortus-Solutions/JSONPrettyPrint: Pretty Print JSON objects ยท GitHub
Pretty print JSON objects with line breaks and indentation to make it more human readable. If you have an app that writes JSON files that humans need to easily be able to read, run the JSON through this library first.
Starred by 7 users
Forked by 4 users
Languages ย  ColdFusion 98.6% | HTML 1.4%