home.


NodeJS: Write javascript to JSON file

If you want to write your javascript object to a json file, it’s easy enough:

fs.writeFileSync('thefilename.json', JSON.stringify(your_object))

This will synchronously write your file, too, unlike the other variant which calls a callback when it’s finished.


Tags: nodejs | json
Posted: Tuesday 10 October 2017, 7:40AM

Edit on Github!
comments powered by Disqus