getInt8() reads one byte from a DataView and returns it as a signed whole number from -128 to 127. A byte is 8 bits, the smallest unit of memory, and it can hold 256 different patterns. “Signed” means half of those patterns stand for negative numbers: the bytes 0 to 127 read as themselves, and the bytes 128 to 255 read as -128 to -1. You choose the byte with a byte offset: its position, counted from 0 at the start of the view.
Call getInt8() on a DataView object with the position of the byte you want.
JavaScript
dataview.getInt8(byteOffset)
Call
What it does
view.getInt8(byteOffset)
Reads the single byte at byteOffset and returns a signed whole number from -128 to 127.
view.getInt8(view.byteLength - 1)
Reads the last byte of the view as a signed number.
Part of the original DataView from ES2015, so every modern browser and runtime has it. With one byte there is no byte order to choose, so getInt8() has no littleEndian argument.
Library declarations
JavaScript
DataView.prototype.getInt8(byteOffset)
// returns a Number: -128 to 127
// reads 1 byte starting at byteOffset (counted from the start of the view)
// needs byteOffset < view.byteLength, else RangeError
Parameters
Parameter
Description
byteOffset
Where to start reading, counted in bytes from the start of the view (not of the underlying buffer). It is converted to a whole number, so 1.9 means 1 and "2" means 2. It must be smaller than view.byteLength. A negative or too-large offset throws a RangeError.
Return Value
Return Value
Description
Number
A whole Number from -128 to 127, built from the 1 byte at byteOffset using two’s complement for negative values.
JavaScript Examples
Example 1 — Read Temperature Changes Stored as Signed Bytes
A weather station sends each temperature change as one signed byte. Read all four changes, including two negative ones.
JavaScript
const bytes = new Uint8Array([5, 251, 128, 127]);
const view = new DataView(bytes.buffer);
for (let i = 0; i < view.byteLength; i++) {
console.log("change " + i + ": " + view.getInt8(i) + " degrees");
}
The view starts later.new DataView(buffer, 2) skips the first two bytes, so the view covers only the last 3 bytes of the buffer.
Offsets count from the view start. getInt8(0) reads buffer byte 2 (254, shown as -2), and getInt8(2) reads the last buffer byte (252, shown as -4).
One step too far. Offset 3 is outside the 3-byte view, so getInt8() throws a RangeError even though the buffer itself has 5 bytes.
Compatibility
Browser & Runtime Support
getInt8() has been part of JavaScript since ES2015, when DataView itself was standardised.
✓ ES2015 · Baseline
DataView.prototype.getInt8()
Works in every modern browser and in Node.js, Deno and Bun. It runs on a normal ArrayBuffer, so no special page setup is needed.
100%Modern browser support
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeModern versions · Chromium
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Internet ExplorerRetired browser · not tested here
Legacy
Node.jsCurrent releases · checked on Node 24
Supported
DenoCurrent releases
Supported
BunCurrent releases
Supported
getInt8()All modern engines
Bottom line: Safe to use without a fallback. It also works on a SharedArrayBuffer, but a normal ArrayBuffer is all you need.
Frequently Asked Questions
A whole number from -128 to 127, made from the single byte at the offset you pass. Bytes 128 to 255 come back as negative numbers.
Both read one byte. getUint8() returns 0 to 255, while getInt8() treats the top bit as a minus sign and returns -128 to 127. The byte 200 is 200 for getUint8() and -56 for getInt8().
Byte order only matters when a number is spread over two or more bytes. getInt8() reads exactly one byte, so there is nothing to reorder.
It throws a RangeError. The offset must be at least 0 and smaller than the byteLength of the view.
It gives the same number, but a DataView can mix types in one buffer: you can call getInt8() at offset 0 and getFloat32() at offset 1 on the same view.