0

In Node.js I am getting a buffer result as:

<Buffer 21 61 0b>

How can I convert this to a string like this:

“21610b”

All the methods and suggestions I have seen online are for converting the buffer to a string but that will change the layout. I want to keep the exact same layout as string.

4
  • I am very confused as to why you would do this... this will completely change what the data is... Commented May 29, 2022 at 0:04
  • .toString('hex') maybe? Commented May 29, 2022 at 0:13
  • @about14sheep it sounds stupid but thats how I just need it :/ Commented May 29, 2022 at 0:33
  • @Jonas Wilms that suggestion actually worked!! Thanks. Commented May 29, 2022 at 0:35

1 Answer 1

1

The console summarizes Buffer objects by displaying the first few bytes in hexadecimal notation. To convert a Buffer to a string of hexadecimals, use .toString('hex').

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.