Sometimes we need to modify the JSON string received from the server side. The best way to do it is to use the “reviver” function with JSON.parse.

This post walks through how to modify a JSON string with JSON.parse.

JSON.parse parses a string to JSON. It also accepts an optional second argument — a “reviver” function — that can be used to mold or modify the values being parsed. In JavaScript terms, the reviver is a callback that is invoked on each property value in the JSON data being parsed. It receives two arguments: key and value. You can delete a key-value pair from the JSON by returning undefined, modify the value based on your need, or return the value unchanged.

Here is a simple example that removes a key-value pair and modifies the value of a key.

Hope this helps.

© 2026 Dhanendra Kumar