Apps4Developers

How to Format JSON in Javascript

JSON
Format
JSON Format
JSON Parse
JSON Tree

Format JSON in Javascript

Use Our Online App to see it in Action

Let's use JSON.stringify() to format JSON

Raw JSON

{"name": "Apps4Developers.com","url": "https://apps4developers.com","description": "A collection of web development tutorials and examples","author": {"name": "Apps4Developers.com", "url": "https://apps4developers.com"}}

Format JSON using Javascript

const formattedJSON = JSON.stringify(rawJSON, null, 2);
console.log(formattedJSON);

Output

{
    "name": "Apps4Developers.com",
    "url": "https://apps4developers.com",
    "description": "A collection of web development tutorials and examples",
    "author": {
        "name": "Apps4Developers.com",
        "url": "https://apps4developers.com"
    }
}
© 2022 Apps4Developers. All rights reserved.