javascript
Prettify JSON object or array using JSON.stringify
If you want to prettify JSON data with fixed spaces in the output, you can use JSON.stringify() method
const json_data = {id: 10001, name: "Tokyo", show: "La Casa De papel"};
const pretty_json_str = JSON.stringify(json_data, undefined, 4);
Output
{
"id": 10001,
"name": "Tokyo",
"show": "La Casa De papel"
}
"id": 10001,
"name": "Tokyo",
"show": "La Casa De papel"
}
LIVE DEMO
Was this helpful?
Similar Posts
- Filter an Array using object key value in Javascript
- Convert object {key: value} to Array [[key, value]] Javascript
- Get all values as array items from an Object in Javascript
- Lodash - Convert paired Array to key value paired object
- Remove duplicates ids from object array
- How to Check If an Array Includes an Object
- Remove an object from array by value in Javascript