Search code snippets, questions, articles...

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);
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.
Output
{
"id": 10001,
"name": "Tokyo",
"show": "La Casa De papel"
}

LIVE DEMO

Was this helpful?
0 Comments