Lodash _.conforms() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

Creates a function that invokes the predicate properties of source with the corresponding property values of a given object, returning true if all predicates return truthy, else false. Part of Lodash Util since 4.0.0 (stable — not deprecated).

Note: Equivalent to _.conformsTo with source partially applied.

Syntax

Call _.conforms. Start with this line.

Lodash
_.conforms(source)
CallWhat it does
_.conforms(source)Primary signature.
_.conforms(...)Call the util helper.

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

Library declarations
Lodash
_.conforms(source)

Parameters

ParameterDescription
sourceRequired. Object of property predicates

Return Value

Return ValueDescription
*New spec function (object) => boolean

Lodash Examples

Example 1 — Official: Filter b > 1

Keep objects whose b property passes a predicate.

Lodash
var objects = [
  { a: 2, b: 1 },
  { a: 1, b: 2 }
];

_.filter(objects, _.conforms({ b: function (n) { return n > 1; } }));
// → [{ a: 1, b: 2 }]
Try It Yourself

How It Works

  1. Spec. _.conforms({ b: … }) builds a checker for key b.
  2. First item. b is 1 → 1 > 1 is false → dropped.
  3. Second item. b is 2 → passes → kept.
  4. Filter. Result is [{ a: 1, b: 2 }].

Example 2 — Direct Boolean Check

Call the returned function on one object.

Lodash
var isActive = _.conforms({
  active: function (v) { return v === true; }
});

console.log(isActive({ id: 1, active: true }));   // true
console.log(isActive({ id: 2, active: false }));  // false
Try It Yourself

How It Works

  1. Build. One predicate for active.
  2. Pass. active: true → predicate truthy → true.
  3. Fail. active: false → predicate false → false.
  4. Reuse. Same isActive works in filters or guards.

Example 3 — Multiple Predicates

Every listed key must pass — like AND across properties.

Lodash
var ok = _.conforms({
  age: function (n) { return n >= 18; },
  score: function (n) { return n >= 70; }
});

console.log(ok({ age: 20, score: 80 })); // true
console.log(ok({ age: 20, score: 50 })); // false
console.log(ok({ age: 16, score: 90 })); // false
Try It Yourself

How It Works

  1. AND. Both age and score must pass.
  2. First. 20 and 80 → both OK → true.
  3. Second. Score 50 fails → false.
  4. Third. Age 16 fails → false.

Example 4 — Extra Properties Are OK

Keys not in source are not checked.

Lodash
var hasBigB = _.conforms({
  b: function (n) { return n > 1; }
});

console.log(hasBigB({ a: 9, b: 2, c: 'x' })); // true
console.log(hasBigB({ b: 0, z: 1 }));         // false
Try It Yourself

How It Works

  1. Only b. Spec lists key b only.
  2. Extras. a and c are ignored.
  3. Pass. b: 2 satisfies > 1.
  4. Fail. b: 0 fails even if z exists.

Example 5 — conforms vs matches

Predicates vs exact (partial) value matching.

Lodash
var obj = { a: 1, b: 2 };

console.log(_.conforms({ b: function (n) { return n > 1; } })(obj));
// → true

console.log(_.matches({ b: 2 })(obj));
// → true

console.log(_.matches({ b: 3 })(obj));
// → false
Try It Yourself

How It Works

  1. conforms. Runs a function on b → range/type checks.
  2. matches. Checks whether values equal the pattern.
  3. Same hit. b: 2 matches both styles here.
  4. Choose. Logic per field → conforms; fixed shape → matches.

Browser & Runtime Support

_.conforms is a Lodash Util helper since 4.0.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.0.0+

_.conforms()

Available in [email protected] full builds and the lodash/conforms modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.0+
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
_.conforms Lodash 4.0.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import conforms from "lodash/conforms" for smaller bundles. Use it to build reusable property-predicate checkers for filter and cond.

Frequently Asked Questions

_.conforms(source) returns a function that checks an object: for each key in source, it runs the predicate on object[key]. All predicates must return truthy. Official use: _.filter(objects, _.conforms({ b: n => n > 1 })).
The created function is equivalent to _.conformsTo with source partially applied. Use conforms for a reusable predicate; conformsTo for a one-shot boolean check.
Only the property value (object[key]), not the whole object. Cross-field rules need a custom wrapper.
No. Only keys listed in source are tested. Extra keys on the target object are ignored.
_.matches compares values with partial deep equality. _.conforms runs custom predicate functions per key (ranges, types, regexes).
Use import conforms from "lodash/conforms" or require("lodash/conforms"). Full build: import _ from "lodash" then _.conforms.

Next: _.constant()

Create a function that always returns the same value.

_.constant() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

10 people found this page helpful