Lodash _.isPlainObject() method

Beginner
⏱️ 5 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.isPlainObject(value) narrows values to dictionary-style objects only.
  • Why class instances, arrays, maps, and dates fail the check.
  • How Object.create(null) still qualifies as plain per the lodash docs.
  • Where this check fits in config validation and safe JSON ingestion.

Prerequisites

You completed or skimmed the _.isObjectLike lesson—this helper tightens it down to true POJOs.

  • You know the difference between an object literal and a class instance.
  • Try-it labs load lodash from the CDN.

Overview

Reach for _.isPlainObject when you want to confirm a value is a dictionary-style bag of keys—safe to spread, merge, or serialize—without accidentally treating arrays, dates, or class instances as configuration.

POJOs only

Accepts literals and new Object(); rejects class instances.

Null-proto OK

Object.create(null) records still pass the check.

Config-safe

Ideal gate before merging options or sanitizing JSON payloads.

Syntax

javascript
_.isPlainObject(value)
  • value: any value to test.
  • Returns: true when the value's [[Prototype]] is Object.prototype or null; otherwise false.
1

Object literals and new Object()

Everyday dictionaries created with {} or the constructor pass cleanly—the lodash docs baseline.

javascript
import isPlainObject from "lodash/isPlainObject";

console.log(
  "literal: " + isPlainObject({ x: 0, y: 0 }) + "\n" + // true
  "ctor: " + isPlainObject(new Object())                // true
);
Try it Yourself
2

Class instances and built-ins fail

Constructors set their own prototype, so the value is no longer "plain" per lodash.

javascript
import isPlainObject from "lodash/isPlainObject";

function Foo() {
  this.a = 1;
}

console.log(
  "fooInst: " + isPlainObject(new Foo()) + "\n" +  // false (lodash docs)
  "arr: " + isPlainObject([1, 2, 3]) + "\n" +       // false
  "map: " + isPlainObject(new Map())                // false
);
Try it Yourself
3

Object.create(null) and nullish

Prototype-less records still count as plain; null and undefined never do.

javascript
import isPlainObject from "lodash/isPlainObject";

console.log(
  "noProto: " + isPlainObject(Object.create(null)) + "\n" + // true (lodash docs)
  "nullVal: " + isPlainObject(null) + "\n" +                 // false
  "undef: " + isPlainObject(undefined)                       // false
);
Try it Yourself

📋 _.isPlainObject vs related checks

API / patternBehavior
_.isPlainObject(x)Only literals, new Object(), or Object.create(null).
_.isObject(x)Loose—classes, functions, and arrays all pass.
_.isObjectLike(x)Non-nullish with typeof === "object"—still broad.
Object.getPrototypeOf(x) === Object.prototypeManual equivalent; misses the null-prototype case.

Pitfalls to avoid

Classes

Class trap

Instances of your own classes fail—don't use this check to validate domain models.

Frames

Cross-realm objects

Lodash works across realms via tag checks, but exotic host objects can still surprise you—verify with your runtime.

Merging

Spread carefully

Confirm both sides are plain before { ...a, ...b }—arrays spread as positional values, not keys.

❓ FAQ

Any value created by the Object constructor (literals or new Object()) or one whose [[Prototype]] is null—class instances and built-ins like Map, Date, or arrays fail.
Custom constructors set the prototype to Foo.prototype, not Object.prototype, so lodash treats the instance as a class instance, not a plain dictionary.
No. _.isObject is loose (functions and arrays pass); _.isPlainObject only accepts simple records that look like config bags or JSON-style hashes.
Mostly yes—lodash uses internal tag checks, so plain objects from iframes or worker contexts are usually identified correctly.

Summary

  • Purpose: confirm a value is a dictionary-style POJO before merging, spreading, or serializing.
  • Remember: class instances and built-ins fail; Object.create(null) still passes.
  • Next: explore more on Lodash _.isRegExp().
Did you know?

_.isPlainObject(Object.create(null)) returns true—lodash treats prototype-less dictionaries as plain because they behave like fresh records, not class instances.

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.

6 people found this page helpful