Favorites

JavaScript Math.ceil() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Math.ceil()
JavaScript Math Static methodThis method is supported by all modern browsers.
Updated 28th November 2026

The Math.ceil() static method rounds a number up to the next whole number.

Description

The Math.ceil() static method always rounds up to the next largest integer. Whole numbers are returned unchanged. A common use is working out how many pages or boxes you need: Math.ceil(items / perPage).

For negative numbers, rounding up means moving towards zero, so Math.ceil(-4.7) is -4. To round up to a number of decimal places, scale first: Math.ceil(x * 100) / 100, keeping in mind that floating point values can make that slightly off at the edges.

Typical uses are working out how many pages, rows or containers are needed to hold a number of items, where any remainder needs one more. Like every member of Math, it's called on the Math object itself rather than on a number, and it only works with the Number type: passing a BigInt throws a TypeError.

Syntax

Math.ceil(x)

Parameters

  • xA number.

Return Value

The smallest integer greater than or equal to x.

Example

console.log(Math.ceil(4.1));
console.log(Math.ceil(4));
console.log(Math.ceil(-4.7));
console.log('Pages:', Math.ceil(53 / 10));

Browser Support

The following information will show you the current browser support for the Math.ceil() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee