Lodash _.ceil() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Computes number rounded up to precision. Part of Lodash 4.x Math (since 3.10.0).

Pass the numbers or collection shown below. Check the return value before you chain another math helper.

Syntax

Call _.ceil. Start with this line.

Lodash
_.ceil(number, [precision=0])
CallWhat it does
_.ceil(number, [precision=0])Primary signature.

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

Library declarations
Lodash
_.ceil(number, [precision=0])

Parameters

ParameterDescription
numberRequired. Value to round up (coerced with toNumber)
precisionOptional. Places to round to; default 0; capped at 292

Return Value

Return ValueDescription
*Rounded-up number (or NaN if input is not numeric)

Lodash Examples

Example 1 — Default Precision

Round up to the next whole number.

Lodash
_.ceil(4.006);
// → 5
Try It Yourself

How It Works

  1. Default. Omitted precision means 0.
  2. Up. Any fractional part pushes toward the next integer above.
  3. Native. Same idea as Math.ceil(4.006).
  4. Docs. Matches the first official example.

Example 2 — Decimal Precision

Keep two decimal places, still rounding up.

Lodash
_.ceil(6.004, 2);
// → 6.01
Try It Yourself

How It Works

  1. Precision 2. Target is hundredths.
  2. Value. 6.004 is just above 6.00.
  3. Ceil. Rounds up to 6.01 (not down to 6.00).
  4. Shift. Lodash uses exponential shifting to reduce float noise.

Example 3 — Negative Precision

Round up to the nearest hundred.

Lodash
_.ceil(6040, -2);
// → 6100
Try It Yourself

How It Works

  1. −2. Means “nearest 10²” → nearest hundred.
  2. Between. 6040 sits between 6000 and 6100.
  3. Up. Ceil chooses 6100.
  4. Tip. −1 → tens, −3 → thousands.

Example 4 — Negative Numbers

“Up” still means toward +Infinity.

Lodash
_.ceil(-4.1);
// → -4

_.ceil(-4.1, 0);
// → -4
Try It Yourself

How It Works

  1. Number line. -4 is to the right of -4.1.
  2. Toward +∞. That is the ceil direction.
  3. Contrast. _.floor(-4.1) → -5.
  4. Trap. “Away from zero” is not what ceil means for negatives.

Example 5 — ceil vs floor vs round

Same input, three directions.

Lodash
[
  _.ceil(4.4),
  _.floor(4.4),
  _.round(4.4)
];
// → [5, 4, 4]
Try It Yourself

How It Works

  1. ceil. Always up → 5.
  2. floor. Always down → 4.
  3. round. Nearest → 4 (4.4 is closer to 4).
  4. Family. All three share Lodash’s precision helper.

Browser & Runtime Support

_.ceil is a Lodash 4.x Math helper (since 3.10.0). It builds on native Math.ceil plus Lodash number coercion.

✓ Stable · Lodash 3.10.0+

_.ceil()

Available in [email protected] full builds and the lodash/ceil modular import. Works in evergreen browsers and Node / Bun / Deno when Lodash is installed.

100% With Lodash 4.x
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
_.ceil Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import ceil from "lodash/ceil" for smaller builds.

Frequently Asked Questions

_.ceil(number, [precision=0]) rounds number up (toward +Infinity) to the given precision. With precision 0 it matches Math.ceil for finite numbers.
Positive precision keeps that many decimal places (rounded up). Negative precision rounds up to tens (−1), hundreds (−2), and so on — e.g. _.ceil(6040, -2) → 6100.
ceil always rounds toward +Infinity. floor rounds toward −Infinity. round goes to the nearest value (ties away from zero in Lodash’s Math.round path).
Yes. _.ceil(-4.1) → -4 because -4 is greater than -4.1 (toward +Infinity).
Yes. The value is passed through toNumber, so _.ceil('4.2') → 5. Non-numeric strings become NaN.
Use import ceil from "lodash/ceil" or require("lodash/ceil") for tree-shaking. Full build: import _ from "lodash" then _.ceil.

Next: _.divide()

Divide two numbers with Lodash’s math helper.

_.divide() 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.

10 people found this page helpful