getBigInt64() reads eight bytes from a DataView and returns a signed 64-bit whole number as a BigInt, from -9223372036854775808n to 9223372036854775807n. A normal Number cannot hold every whole number that large exactly, which is why this method returns a BigInt (a whole number written with a trailing n). Like the other multi-byte methods, it reads big-endian unless you pass true.
Reads the 8 bytes starting at byteOffset in big-endian order (most significant byte first) and returns a signed whole number from -9223372036854775808n to 9223372036854775807n.
view.getBigInt64(byteOffset, true)
Reads the same 8 bytes in little-endian order (least significant byte first), the order used by most file formats from PCs, such as WAV and BMP.
Added in ES2020 together with BigInt. Every current browser and runtime has it. Unlike a BigInt64Array, a DataView has no alignment rule: getBigInt64() works at any byte position, even one that is not a multiple of 8.
Library declarations
JavaScript
DataView.prototype.getBigInt64(byteOffset)
DataView.prototype.getBigInt64(byteOffset, littleEndian)
// returns a BigInt: -9223372036854775808n to 9223372036854775807n
// reads 8 bytes starting at byteOffset (counted from the start of the view)
// needs byteOffset + 8 <= view.byteLength, else RangeError
// littleEndian: false or left out = big-endian
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. All 8 bytes must fit: byteOffset + 8 may not be larger than view.byteLength. A negative or too-large offset throws a RangeError.
littleEndian
Optional. Leave it out (or pass false) for big-endian: the most significant of the 8 bytes comes first. Pass true for little-endian: the least significant byte comes first. Any truthy value, such as 1, also means little-endian.
Return Value
Return Value
Description
BigInt
A BigInt from -9223372036854775808n to 9223372036854775807n, built from the 8 bytes at byteOffset. Print it with String(), and use Number() only when it is small enough.
JavaScript Examples
Example 1 — Read a Time Stored in Milliseconds
A timestamp in milliseconds is too big for 32 bits, so binary formats store it in 8 bytes. Read it and turn it into a date.
JavaScript
const view = new DataView(new ArrayBuffer(8));
view.setBigInt64(0, 1735689600000n); // milliseconds since 1970
const ms = view.getBigInt64(0);
console.log(String(ms)); // 1735689600000
console.log(new Date(Number(ms)).toISOString()); // 2025-01-01T00:00:00.000Z
Eight bytes of ff.new Uint8Array(8).fill(0xff) sets all 64 bits to 1.
Signed sees -1. In two’s complement all bits on means -1, so getBigInt64() returns -1n while getBigUint64() returns the maximum unsigned value.
Clear the sign bit. Changing the first byte to 7f turns the top bit off, and the same 8 bytes now read as the largest positive value, 9223372036854775807n.
Example 3 — Keep a Huge Database ID Exact
Some databases hand out 64-bit IDs larger than JavaScript Numbers can hold exactly. Read one with getBigInt64() and see what Number() would do.
JavaScript
const view = new DataView(new ArrayBuffer(8));
view.setBigInt64(0, 9007199254740993n, true); // a database row id
const id = view.getBigInt64(0, true);
console.log(String(id)); // 9007199254740993
console.log(String(Number(id))); // 9007199254740992
console.log(id > BigInt(Number.MAX_SAFE_INTEGER)); // true
An ID above the safe limit. 9007199254740993 is larger than Number.MAX_SAFE_INTEGER (9007199254740991).
BigInt keeps every digit.getBigInt64(0, true) reads the little-endian bytes back as exactly 9007199254740993n.
Number() would lose it. Converting to a Number rounds the ID to 9007199254740992, a different row. Keep such IDs as BigInt or as strings.
Compatibility
Browser & Runtime Support
getBigInt64() arrived in ES2020, together with BigInt and BigInt64Array.
✓ ES2020 · Widely available
DataView.prototype.getBigInt64()
Every current browser and runtime supports it. Only very old engines without BigInt lack it.
97%Current 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 ExplorerNo BigInt support
Not supported
Node.jsCurrent releases · checked on Node 24
Supported
DenoCurrent releases
Supported
BunCurrent releases
Supported
getBigInt64()All current engines
Bottom line: Safe in today’s browsers. If you must support an engine without BigInt, check typeof BigInt === "function" first.
Frequently Asked Questions
A BigInt, such as -5n. typeof view.getBigInt64(0) is "bigint", not "number".
A Number can only hold whole numbers exactly up to 9007199254740991. A 64-bit integer goes much higher, so a BigInt is needed to keep every digit.
Use String(value) or value.toString(). Both give the digits without the trailing n.
getBigInt64() treats the top bit as a sign and returns -2 to the power 63 up to 2 to the power 63 minus 1. getBigUint64() returns 0 up to 2 to the power 64 minus 1.
No, mixing BigInt and Number throws a TypeError. Use a BigInt literal such as 1n, or convert one side first.