You need to parse each octet back to number, and use that value to get a character, something like this:

function bin2String(array) {
  var result = "";
  for (var i = 0; i < array.length; i++) {
    result += String.fromCharCode(parseInt(array[i], 2));
  }
  return result;
}

bin2String(["01100110", "01101111", "01101111"]); // "foo"

// Using your string2Bin function to test:
bin2String(string2Bin("hello world")) === "hello world";

Edit: Yes, your current string2Bin can be written more shortly:

function string2Bin(str) {
  var result = [];
  for (var i = 0; i < str.length; i++) {
    result.push(str.charCodeAt(i).toString(2));
  }
  return result;
}

But by looking at the documentation you linked, I think that the setBytesParameter method expects that the blob array contains the decimal numbers, not a bit string, so you could write something like this:

function string2Bin(str) {
  var result = [];
  for (var i = 0; i < str.length; i++) {
    result.push(str.charCodeAt(i));
  }
  return result;
}

function bin2String(array) {
  return String.fromCharCode.apply(String, array);
}

string2Bin('foo'); // [102, 111, 111]
bin2String(string2Bin('foo')) === 'foo'; // true
Answer from Christian C. Salvadó on Stack Overflow
🌐
Adeva
adevait.com › nodejs › convert-node-js-buffer-to-string
How to Convert Node.js Buffer to String | Toptal®
May 26, 2026 - In a nutshell, it’s easy to convert a Buffer object to a string using the toString() method. You’ll usually want the default UTF-8 encoding, but it’s possible to indicate a different encoding if needed.
🌐
Node.js
nodejs.org › api › buffer.html
Buffer | Node.js v26.10.0 Documentation
Each character is encoded using a single byte. Characters that do not fit into that range are truncated and will be mapped to characters in that range. Converting a Buffer into a string using one of the above is referred to as decoding, and converting a string into a Buffer is referred to as encoding.
🌐
GitHub
gist.github.com › taterbase › 2784890
Convert bytes to string Javascript · GitHub
function bin2string(array){ var result = ""; for(var i = 0; i < array.length; ++i){ result+= (String.fromCharCode(array[i])); } return result; }
🌐
W3Schools
w3schools.com › nodejs › met_buffer_tostring.asp
Node.js buffer toString() Method
If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Find elsewhere
🌐
Programmingwithswift
programmingwithswift.com › how-to-convert-byte-array-to-string-with-javascript
How to convert a byte array to String with JavaScript
December 28, 2020 - In this tutorial I will show you how you can convert a byte array to a string using JavaScript. I was busy with a task recently that required me to do this, luckily, JavaScript makes this easy with the built in String.fromCharCode() function. Let's ...
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-convert-byte-array-to-string-in-javascript
JavaScript – Convert Byte Array to String | GeeksforGeeks
November 26, 2024 - There is an NPM package called arraybuffer-to-string used to decode array buffers in actual strings. The package not only converts the buffer to 'utf8' string but also it converts the buffer to many forms like base64 encoded string, ... Blob ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-byte-array-to-string-in-javascript
JavaScript - Convert Byte Array to String - GeeksforGeeks
July 23, 2025 - In Node.js, the Buffer class provides a toString method to decode byte arrays into strings.
🌐
Mastering JS
masteringjs.io › tutorials › node › buffer-to-string
Using the Buffer `toString()` Function in Node.js - Mastering JS
August 21, 2020 - For example, by calling .toString('hex'), you get a string representation of the buffer where each byte is encoded as 2 hexadecimal characters.
🌐
Medium
medium.com › @ryan_forrester_ › buffer-to-string-in-javascript-how-to-guide-b24027575419
Buffer to String in JavaScript (How To Guide) | by ryan | Medium
January 7, 2025 - Converting a buffer to a string is a common requirement when dealing with data processing in JavaScript.
🌐
EyeHunts
tutorial.eyehunts.com › home › javascript byte array to string | example code
JavaScript byte Array to String | Simple Example code - EyeHunts
December 8, 2021 - An array is actually the ASCII code for a character. String.fromCharCode will convert each code into a character. Use String.fromCharCode with for loop to convert byte array to String in JavaScript.
🌐
Daniel Lemire's blog
lemire.me › blog › 2023 › 12 › 08 › fast-buffer-to-string-conversion-in-javascript-with-a-lookup-table
Fast Buffer-to-String conversion in JavaScript with a Lookup Table – Daniel Lemire's blog
December 8, 2023 - When programming in a JavaScript environment such as Node.js, you might recover raw data from the network and need to convert the bytes into strings. In a system such as Node.js, you may represent such raw bytes using a Buffer instance. You can conveniently convert a Buffer instance into a JavaScript (mybuffer.toString()). But, maybe surprisingly, … Continue reading Fast Buffer-to-String conversion in JavaScript with a Lookup Table
🌐
GitHub
gist.github.com › robingenz › 37179fcafd3506512efd68f80930de94
Byte array to string converter in JavaScript · GitHub
Byte array to string converter in JavaScript · Raw · convertBytesToString.js · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
W3Resource
w3resource.com › node.js › nodejs-buffer.php
Using Buffers in Node.js - w3resource<
November 13, 2023 - The Buffer class is global. It deals with binary data directly and can be constructed in a variety of ways. Converting between Buffers and JavaScript string objects requires an explicit encoding method.
🌐
Designcise
designcise.com › web › tutorial › how-to-convert-a-javascript-byte-array-to-a-string
How to Convert a JavaScript Byte Array to a String? - Designcise
April 9, 2023 - In JavaScript, you can convert an array of bytes to string by using the TextDecoder API with UTF-8 encoding, for example, in the following way: function fromBinaryArray(bytes) { const decoder = new TextDecoder('utf-8'); return decoder.decode(bytes); ...
🌐
Rogueamoeba
weblog.rogueamoeba.com › 2017 › 02 › 27 › javascript-correctly-converting-a-byte-array-to-a-utf-8-string
JavaScript: Correctly Converting a Byte Array to a UTF-8 String
February 27, 2017 - When converting this text to a stream of bytes, the special characters need to be encoded with something like UTF-8. When converting from a stream of bytes back to a string, the UTF-8 must be decoded back the right special characters. This is a very old, very solved problem, but it is still surprisingly easy to screw it up. Searching for “JavaScript convert bytes to string” will bring you to numerous code samples and Stack Overflow questions.