Skip to content

Home

Convert between degrees and radians in JavaScript

Degrees to radians

JavaScript's Math.PI constant can be used to convert an angle from degrees to radians. The conversion formula is radians = degrees * Math.PI / 180.0.

const degreesToRads = deg => (deg * Math.PI) / 180.0;

degreesToRads(90.0); // ~1.5708

Radians to degrees

Conversely, the conversion formula from radians to degrees is degrees = radians * 180.0 / Math.PI.

const radsToDegrees = rad => (rad * 180.0) / Math.PI;

radsToDegrees(Math.PI / 2); // 90

More like this

Start typing a keyphrase to see matching snippets.