How to display Node.js raw Buffer data as Hex string?

Sometimes, we want to display Node.js raw Buffer data as Hex string.

In this article, we’ll look at how to display Node.js raw Buffer data as Hex string.

How to display Node.js raw Buffer data as Hex string?

To display Node.js raw Buffer data as Hex string, we can use the buffer toString method.

For instance, we write

buff.toString('hex');

to convert the buff buffer to a string with toString.

We call toString with 'hex' to return a hex version of the raw buffer data.

Conclusion

To display Node.js raw Buffer data as Hex string, we can use the buffer toString method.