Favorites

JavaScript Math.PI Property

☕
Enjoying this site?

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

Buy us a coffee
Math.PI
JavaScript Math Static propertyThis property is supported by all modern browsers.
Updated 28th November 2026

Math.PI is the ratio of a circle's circumference to its diameter, approximately 3.14159.

Description

The Math.PI static property represents the ratio of the circumference of a circle to its diameter, π, approximately 3.141592653589793. It's used for circle and angle calculations, including converting degrees to radians: degrees * Math.PI / 180. Like all Math constants, it is read-only.

Because π is irrational, Math.PI is the closest value a JavaScript number can hold, accurate to about 15 decimal places, which is far more than any visual or everyday calculation needs. Results that involve it, such as Math.sin(Math.PI), can be a tiny number instead of exactly zero, so round before comparing or displaying.

In CSS, angles can be written in degrees directly, but JavaScript's trigonometric functions and the Canvas API's arc() method use radians, so Math.PI appears in most drawing code: a full circle is 2 * Math.PI.

Syntax

Math.PI

Value

About 3.14159.

Example

const r = 5;
console.log(Math.PI);
console.log('Area:', (Math.PI * r ** 2).toFixed(2));
console.log('Circumference:', (2 * Math.PI * r).toFixed(2));
console.log('90deg in radians:', 90 * Math.PI / 180);

Browser Support

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

This property 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