16

I visit JSON endpoints that look like: https://dummyjson.com/test

I don't want to manually click the "Pretty-print" checkbox every time.

enter image description here

enter image description here

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


Bonus questions:

  • Why would anyone not want Pretty-print enabled?
  • Why wouldn't it at least be enabled by default?
Pat Myron
  • 129
Ryan
  • 2,388

2 Answers2

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.

Ali Khakbaz
  • 1,057
1

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.