pretty json code example

Example 1: json stringify pretty

JSON.stringify(jsonobj,null,'\t')

Example 2: JSON.stringify pretty

var str = JSON.stringify(obj, null, 2); // spacing level = 2

Example 3: pretty json python

print(json.dumps(dict, indent=4))

Example 4: online json viewer

Online JSON beautifier: https://codebeautify.org/jsonviewer

JSON pretty print in Python:

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

Example 5: json beautify

fetch('https://fakestoreapi.com/products/6',{
            method:"DELETE"
        })
            .then(res=>res.json())
            .then(json=>console.log(json))

Tags:

Php Example