JSON.parse vs JSON.stringify

JSON.parse and JSON.stringify are two JavaScript functions that are used to convert JavaScript objects to JSON strings and vice versa. Today I wanted to test do they consume about the same amount of computation time.  Therefore I created a simple jsPerf test to find out. I had a gut feeling that JSON.stringify might be faster because parsing felt more difficult task.

The results show that the two functions are roughly equivalent in time. As an afterthought, this makes sense. Under the hood, both operations need to work with the JavaScript language syntax. They just do it in a different order.

Test it yourself at jsperf.com/json-parse-vs-json-stringify

Akseli Palén
Hi! I am a creative full-stack web developer and entrepreneur with strong focus on building open source packages for JavaScript community and helping people at StackOverflow. I studied information technology at Tampere University and graduated with distinction in 2016. I wish to make it easier for people to communicate because it is the only thing that makes us one.