Skip to content
Advertisement

Download Object As Formatted JSON File

I followed this guide to download a JSON object from the browser. This is what my code looks like:

JavaScript

But this gives me a single line file that is hard to read. Is there an easy way to format it as a readable JSON file, with newlines and indentation?

Advertisement

Answer

The JSON.stringify has three parameters, you can use third parameter for that

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement