You can instantiate Uint16Array from Uint8Array buffer value:

const uint8Array = new Uint8Array([1, 164, 5, 57])
const uint16Array = new Uint16Array(uint8Array.buffer)
// Uint16Array(2) [ 41985, 14597 ]
Answer from Metu on Stack Overflow
🌐
WebDeveloper.com
webdeveloper.com › community › 300471-how-to-convert-uint8array-to-uint16array-or-string
How to convert Uint8Array to Uint16Array or string
// — STEP 4 (PROBLEM) — // – OPTION A (WORKING) – // if I save x4 to binary file, and then read it (like in STEP 1) // then data is the same as in original // this means that load file 1, do STEP 2, do STEP 3, save as file 2, // load file 2 will result in file 1 has exactly the same // bytes as file 2 (compared in Total Commander) // – OPTION B (PROBLEM) – // problem is how to convert this Uint8Array (from STEP 3) // back to 16 bit ASCII codes array (like STEP 2), // or just to correct JavaScript string // (like it was in STEP 1 before you started to convert it to arrays) // to make this question more simple: // how to revert from step 3 to step 1 ·
🌐
SitePoint
sitepoint.com › javascript
How to convert Uint8Array to Uint16Array or string
September 8, 2014 - How to revert from step 3 to step 1? I read a lot and used google before asking. Here is my listing with comments: // --- STEP 1 --- x1=getFile('filename'); // I get raw 16 bit binary string (it is not just a text) // --- STEP 2 --- x2=x1.split('').map(function(x){return x.charCodeAt(0);}); // I convert string to array with ASCII codes (some of them are above 255) // first four elements of this array: 63367 63457 95 22 // --- STEP 3 --- x3=new Uint8Array(x2); // I convert ASCII codes to 8 ...
🌐
GitHub
gist.github.com › MikkoH › f8c5148871bb3ba57455
Converting between TypedArrays · GitHub
Converting between TypedArrays. GitHub Gist: instantly share code, notes, and snippets.
🌐
Stack Overflow
stackoverflow.com › questions › 25729350 › how-to-convert-uint8array-to-uint16array-or-string
How to convert Uint8Array to Uint16Array or string
// --- STEP 1 --- x1=getFile('filename'); // I get raw 16 bit binary string (it is not just a text) // --- STEP 2 --- x2=x1.split('').map(function(x){return x.charCodeAt(0);}); // I convert string to array with ASCII codes (some of them are above 255) // first four elements of this array: 63367 63457 95 22 // --- STEP 3 --- x3=new Uint8Array(x2); // I convert ASCII codes to 8 bit data array // first four elements of this array: 135 225 95 22 // --- STEP 4 (PROBLEM) --- // - OPTION A (WORKING) - // if I save x4 to binary file, and then read it (like in STEP 1) // then data is the same as in ori
🌐
haikel-fazzani
haikel-fazzani.eu.org › home › javascript snippets › javascript typed arrays: uint8array, uint16array, and uint32array
JavaScript Typed Arrays: Uint8Array, Uint16Array, and Uint32Array
July 14, 2025 - Choosing the appropriate Typed Array—Uint8Array, Uint16Array, or Uint32Array—is essential for optimizing performance and memory usage when working with binary data in JavaScript.
🌐
JavaScript.info
javascript.info › tutorial › binary data, files
ArrayBuffer, binary arrays
July 11, 2022 - Uint8Array – treats each byte ... value is called a “8-bit unsigned integer”. Uint16Array – treats every 2 bytes as an integer, with possible values from 0 to 65535....
Find elsewhere
🌐
Exploring JS
exploringjs.com › impatient-js › ch_typed-arrays.html
32 Typed Arrays: handling binary data (advanced)
This web page has moved · “JavaScript for impatient programmers” is now “Exploring JavaScript” · You’ll be transported to the new website
🌐
Stack Overflow
stackoverflow.com › questions › 70734367 › nodejs-uint8array-uint16array-uint32array
javascript - Nodejs Uint8Array,Uint16Array, Uint32Array
But Uint16Array takes 2 bytes for an integer, that is, the number must be different and the size of the array is 2. What am I wrong about and which buffer to pass to these constructors in order to visually see the difference?
🌐
Web Developer
webdeveloper.com › d › 300471-how-to-convert-uint8array-to-uint16array-or-string
How to convert Uint8Array to Uint16Array or string - WebDeveloper.com Forums
Where web developers and designers learn and share how to design websites, build mobile applications, create WordPress themes, write code, HTML, JavaScript, PHP, Java, and much more!
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint16Array
Uint16Array - JavaScript - MDN Web Docs
July 10, 2025 - The Uint16Array typed array represents an array of 16-bit unsigned integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).
🌐
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
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › TypedArray › from
TypedArray.from() - JavaScript - MDN Web Docs
July 10, 2025 - Uint8Array · Uint8ClampedArray · Int16Array · Uint16Array · Int32Array · Uint32Array · Float16Array · Float32Array · Float64Array · BigInt64Array · BigUint64Array · arrayLike · An iterable or array-like object to convert to a typed array. mapFn Optional ·
🌐
Medium
medium.com › @rgndunes › playing-with-binary-data-arraybuffer-typedarray-uint8-uint16-dataview-blob-c29ff690f593
Playing with Binary data — ArrayBuffer, TypedArray (Uint8, Uint16), DataView, Blob | by Divyansh Singh | Medium
June 11, 2024 - let uint8Array = new Uint8Array(4); console.log(uint8Array.length); // Output: 4 (number of elements) console.log(uint8Array.byteLength); // Output: 4 (size in bytes) let uint16Array = new Uint16Array(4); console.log(uint16Array.length); // Output: 4 (number of elements) console.log(uint16Array.byteLength); // Output: 8 (size in bytes, each element is 2 bytes)
🌐
Bun
bun.sh › guides › binary › arraybuffer-to-typedarray
Convert an ArrayBuffer to a Uint8Array - Bun
const buffer = new ArrayBuffer(64); const arr1 = new Uint8Array(buffer); const arr2 = new Uint16Array(buffer); const arr3 = new Uint32Array(buffer); const arr4 = new Float32Array(buffer); const arr5 = new Float64Array(buffer); const arr6 = new ...
🌐
W3Schools
w3schools.com › jsref › jsref_obj_typed_array.asp
JavaScript Typed Arrays
Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array BigInt64Array BigUint64Array Float16Array Float32Array Float64Array JS Typed Reference