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