Buffer class provides a built-in .toString() method that converts a Buffer to a string.
You can optionally specify an encoding and byte range.
See Docs > API > Binary Data for complete documentation on manipulating binary data with Bun.
Buffer class provides a built-in .toString() method that converts a Buffer to a string.
const buf = Buffer.from("hello");
const str = buf.toString();
// => "hello"
const buf = Buffer.from("hello world!");
const str = buf.toString("utf8", 0, 5);
// => "hello"
Was this page helpful?