convert buffer to json nodejs

const buffer = Buffer.from('{"key":"value"}'); const json = buffer.toString('utf8');

Explanation: 1. Create a buffer using the Buffer.from() method and pass in the JSON string as the argument. 2. Convert the buffer to a JSON object using the toString('utf8') method, specifying the encoding as 'utf8'.