Lodash _.isBuffer() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is a Node.js Buffer. When Buffer exists, Lodash forwards to Buffer.isBuffer; otherwise it returns false. Since Lodash 4.3.0.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.isBuffer. Start with this line.

Lodash
_.isBuffer(value)
CallWhat it does
_.isBuffer(value)Primary signature.

Prefer import isBuffer from "lodash/isBuffer" when you want a smaller bundle.

Library declarations
Lodash
_.isBuffer(value)

Parameters

ParameterDescription
valueRequired. The value to check

Return Value

Return ValueDescription
*true if Buffer, else false

Lodash Examples

Example 1 — Official Idea: Real Buffer

A constructed Buffer passes — use alloc instead of deprecated new Buffer.

Lodash
_.isBuffer(Buffer.alloc(2));
// → true
Try It Yourself

How It Works

  1. Create. Buffer.alloc(2) builds a zero-filled Buffer.
  2. Check. Lodash / Buffer.isBuffer recognizes it.
  3. Result. true.
  4. Docs note. Older samples used new Buffer(2) — avoid that API.

Example 2 — Official: Uint8Array Is False

Typed-array views are not Node Buffers.

Lodash
_.isBuffer(new Uint8Array(2));
// → false
Try It Yourself

How It Works

  1. Create. A plain Uint8Array view.
  2. Check. Not a Buffer instance → false.
  3. Need a Buffer? Buffer.from(view) copies into one.
  4. Typed only? Use _.isTypedArray.

Example 3 — Buffer.from String

UTF-8 bytes from a string are still a Buffer.

Lodash
_.isBuffer(Buffer.from("hello", "utf8"));
// → true

_.isBuffer("hello");
// → false
Try It Yourself

How It Works

  1. Buffer.from encodes the string into bytes.
  2. isBuffer → true for that instance.
  3. Plain string stays a string → false.
  4. Lesson. Encoding does not change the type check’s target.

Example 4 — ArrayBuffer Is Not a Buffer

Raw memory and Node Buffer are different types.

Lodash
_.isBuffer(new ArrayBuffer(8));
// → false

_.isArrayBuffer(new ArrayBuffer(8));
// → true
Try It Yourself

How It Works

  1. ArrayBuffer is the raw byte store.
  2. isBuffer does not treat it as a Node Buffer.
  3. isArrayBuffer is the correct check for that type.
  4. Bridge. Buffer.from(arrayBuffer) when you need a Buffer.

Example 5 — Safe Feature Guard

Isomorphic code should not assume Buffer exists.

Lodash
function isNodeBuffer(value) {
  return typeof Buffer !== "undefined"
    && typeof Buffer.isBuffer === "function"
    && Buffer.isBuffer(value);
}

isNodeBuffer(typeof Buffer !== "undefined" ? Buffer.alloc(1) : null);
// → true in Node / with Buffer polyfill
// → false when Buffer is missing
Try It Yourself

How It Works

  1. Guard typeof Buffer before calling.
  2. Then use Buffer.isBuffer (same as Lodash in Node).
  3. Missing Buffer → treat as not a buffer.
  4. Bundlers that inject Buffer make Lodash’s _.isBuffer work too.

Browser & Runtime Support

_.isBuffer is a Lodash Lang helper (since 4.3.0). It is most useful in Node.js (and Deno/Bun with Buffer). In browsers it only returns meaningful true when Buffer is available at Lodash load (bundler) or you call Buffer.isBuffer after a polyfill.

✓ Stable · Lodash 4.3.0+

_.isBuffer()

Available in [email protected]. Best in Node. Browser CDN builds often stub to false — prefer Buffer.isBuffer for polyfilled demos.

Node-first With Buffer available
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isBuffer Lodash 4.3.0+

Bottom line: In Node, _.isBuffer mirrors Buffer.isBuffer. In bare browser + CDN Lodash, expect false unless you bundle Buffer before Lodash initializes.

Frequently Asked Questions

_.isBuffer(value) returns true if value is a Node.js Buffer instance. It forwards to Buffer.isBuffer when Buffer is available; otherwise it returns false.
No. A plain Uint8Array is not a Buffer. Buffer extends Uint8Array in modern Node, but Buffer.isBuffer distinguishes real Buffer instances.
No. ArrayBuffer is raw memory. Buffer is a Node view/API over bytes. Use _.isArrayBuffer for ArrayBuffer and _.isBuffer for Buffer.
lodash.min.js wires _.isBuffer to a false stub when Buffer is missing at load time. Polyfilling Buffer later does not change that stub. Use Buffer.isBuffer in browser demos, or bundle Lodash with Buffer available.
No. new Buffer() is deprecated and unsafe for untrusted input. Prefer Buffer.alloc, Buffer.allocUnsafe, or Buffer.from.
Use import isBuffer from "lodash/isBuffer" or require("lodash/isBuffer") for tree-shaking. Full build: import _ from "lodash" then _.isBuffer.

Next: _.isDate()

Check whether a value is a real Date instance.

_.isDate() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful