Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to use Node.js buffer module readUIntLE()

Muhammad Ashir

The Buffer.readUIntLE() method is used to read a specified number of bytes as an unsigned little-endian integer from an allocated buffer at a specified offset.

Endianness represents the order of bytes in a computer system. There are two types of endianness: little endian and big endian.

  • Big endian: Big endian stores the most significant bytes (MSB) first.

  • Little endian: Little endian stores the least significant bytes (LSB) first.


buf.readUIntLE(offset, byteLength)


  • offset: Determines the number of bytes to skip before starting to read.
  • byteLength: Determines the number of bytes to read, which must be between 11 and 66 (inclusive).

Return value

Buffer.readUIntLE() returns an integer representation of the bytes read with up to a 48-bit accuracy.


const buf = Buffer.from([0x05, 0x00, 0x00]);

console.log(buf.readUIntLE(0, 3));

In the code above, we have an array of three hexadecimal values from which we create our buffer. Buffer.readUIntLE() starts reading from the 00 offset and reads three bytes in little-endian format. Thus, it reads a hexadecimal value of 0x00 00 05 as an integer value of 5.




Muhammad Ashir
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring