You can use Buffer.from(string[, encoding]). The Buffer class has implemented the Uint8Array interface in Node since v4.x. You can also optionally specify an encoding with which to do string processing in both directions, i.e. buffer.toString([encoding]).

Answer from Patrick Roberts on Stack Overflow
Discussions

Start moving to Uint8Array in new APIs?
There was a suggestion by @jasnell to use Uint8Arrays in new APIs over Buffers as well as a weigh-in by @sindresorhus saying it is easier to author cross-platform APIs when using Uint8Arrays. Here ... More on github.com
🌐 github.com
34
January 19, 2022
Buffer/Uint8Array using lots of memory
Tested in NodeJS Versions: v22.3.0, v20.14.0, v18.20.3, v16.20.2 It appears as though Buffer/Uint8Array consumes much more memory than I would expect. This is particularly obvious with many small i... More on github.com
🌐 github.com
6
June 13, 2024
🌐
npm
npmjs.com › package › uint8arrays
uint8arrays - npm
May 7, 2026 - This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.
      » npm install uint8arrays
    
Published: May 07, 2026
Version: 6.1.1
🌐
GitHub
github.com › nodejs › node › issues › 41588
Start moving to Uint8Array in new APIs? · Issue #41588 · nodejs/node
January 19, 2022 - There was a suggestion by @jasnell to use Uint8Arrays in new APIs over Buffers as well as a weigh-in by @sindresorhus saying it is easier to author cross-platform APIs when using Uint8Arrays. Here is a context #41553 (comment) That is, t...
Author: nodejs
🌐
Node.js
nodejs.org › api › buffer.html
Buffer | Node.js v26.11.1 Documentation
Node.js APIs accept plain <Uint8Array>s wherever Buffers are supported as well.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint8Array › Uint8Array
Uint8Array() constructor - JavaScript - MDN Web Docs
July 10, 2025 - The Uint8Array() constructor creates Uint8Array objects. The contents are initialized to 0 unless initialization data is explicitly provided.
🌐
Stack Overflow
stackoverflow.com › questions › 70734367 › nodejs-uint8array-uint16array-uint32array
javascript - Nodejs Uint8Array,Uint16Array, Uint32Array
To access its underlying buffer (and construct the typed array as a view on it), you need to write new Uint16Array(buffer.buffer); and new Uint8Array(buffer.buffer);.
🌐
Quora
quora.com › What-is-the-relationship-between-a-Buffer-and-an-Uint8Array-in-Node-js
What is the relationship between a Buffer and an Uint8Array in Node.js? - Quora
Answer (1 of 3): tldr - Uint8Array is a general-purpose byte-array that’s available in both nodejs and browsers. Buffer is a subclass of Uint8Array that’s only available in nodejs (for historical reasons). both are primarily used for manipulating binary (byte) data. historically, when nodejs ...
Find elsewhere
🌐
w3tutorials
w3tutorials.net › blog › nodejs-uint8array
Understanding Node.js Uint8Array — w3tutorials.net
One of the fundamental data types that plays a significant role in handling binary data is the Uint8Array. A Uint8Array is a typed array in JavaScript and Node.js, which represents an array of 8 - bit unsigned integers.
🌐
npm
npmjs.com › package › to-uint8array
to-uint8array - npm
July 16, 2021 - import toUint8 from 'to-uint8array' const buffer = Buffer.from('abc') const u8 = new Uint8Array([97]) const u16 = new Uint16Array([0, 1, 2]) const ab = new ArrayBuffer(3) toUint8(u16) // Uint8Array(6) [ 0, 0, 1, 0, 2, 0 ] toUint8(ab) // Uint8Array(3) [ 0, 0, 0 ] toUint8('abc') // Uint8Array(3) [ 97, 98, 99 ] toUint8(buffer) // Uint8Array(3) [ 97, 98, 99 ] toUint8(u8) === u8 // true toUint8(u16) === u16 // false toUint8(ab).buffer === ab // true toUint8(u16).buffer === u16.buffer // true toUint8(buffer) instanceof Uint8Array // true toUint8(buffer) instanceof Buffer // false
      » npm install to-uint8array
    
Published: Jul 16, 2021
Version: 0.1.1
Author: Jimmy Wärting
🌐
Sindre Sorhus
sindresorhus.com › blog › goodbye-nodejs-buffer
Goodbye, Node.js Buffer — Sindre Sorhus
October 24, 2023 - Instead of Buffer#slice(), use Uint8Array#subarray() or Buffer#subarray().
🌐
GitHub
github.com › nodejs › performance › issues › 173
Buffer/Uint8Array using lots of memory · Issue #173 · nodejs/performance
June 13, 2024 - It doesn't appear that the memory used increases much with the size of the Uint8Array. Doubling the size of each Uint8Array from 12 -> 24 only increases the memory usage to 485MB in the above test.
Author: nodejs
🌐
Medium
mookypoo.medium.com › receiving-uint8array-on-node-js-and-saving-on-google-cloud-storage-5682a3151edc
Receiving Uint8Array on Node.js and Saving on Google Cloud Storage | by Soo Kim | Medium
June 3, 2022 - In my previous post, I used bucket.upload() but after some googling, I’ve switched to file.save(), which takes a Buffer as an argument. (1) When you receive the bytes array, create an instance of Uint8Array, which is extended by the Buffer class. (2) Use bucket.file(filename) to create a File object.
🌐
Bun
bun.com › guides › streams › node-readable-to-uint8array
Convert a Node.js Readable to an Uint8Array | Bun Examples
To convert a Node.js Readable stream to an Uint8Array in Bun, you can create a new Response object with the stream as the body, then use bytes() to read the stream into an Uint8Array.
🌐
w3tutorials
w3tutorials.net › blog › nodejs-how-to-create-uintarray
Node.js: How to Create UintArray — w3tutorials.net
One fundamental way to work with ... TypedArray) plays a significant role. A Uint8Array is a fixed-length array that can store unsigned integer values of a specific byte size....
      » npm install buffer-to-uint8array
    
Published: May 20, 2015
Version: 1.1.0
Author: substack
🌐
codelessgenie
codelessgenie.com › blog › how-convert-a-string-to-type-uint8array-in-nodejs
How to Convert a String to Uint8Array in Node.js: Simple Methods Without Custom Parsers — CodeLessGenie.com
But why Uint8Array? Unlike regular JavaScript arrays, typed arrays like Uint8Array provide a memory-efficient way to handle binary data, with fixed-size elements and direct access to raw bytes. The good news? You don’t need to build custom parsers to convert strings to Uint8Array in Node.js.
🌐
npm
npmjs.com › search
uint8array - npm search
Fast SHA-1 digest hash based on Uint8Array, pure JavaScript.
🌐
Bun
bun.com › binary data › convert a buffer to a uint8array
Convert a Buffer to a Uint8Array - Bun
July 7, 2026 - The Node.js Buffer class extends Uint8Array, so no conversion is needed.
🌐
JavaScript.info
javascript.info › tutorial › binary data, files
ArrayBuffer, binary arrays
July 11, 2022 - Uint8Array – treats each byte in ArrayBuffer as a separate number, with possible values from 0 to 255 (a byte is 8-bit, so it can hold only that much).