Ship internal tools in hours, not weeks. Real auth, users, jobs, audit logs, and cohesive UI included. Early access $249 $499 → [Get it now]

How to convert radians to degrees in JavaScript

Converting radians to degrees is essential for displaying trigonometric results, rotation controls, compass displays, and geometric utilities in JavaScript applications. With over 25 years of experience in software development and as the creator of CoreUI, I’ve used this conversion in rotation sliders, angle indicators, and chart label formatting. JavaScript’s Math.atan2(), Math.asin(), and Math.acos() return radians — convert to degrees before displaying to users. For the inverse operation, see how to convert degrees to radians in JavaScript.

Multiply radians by 180 / Math.PI to convert to degrees.

Math.PI * (180 / Math.PI)        // 180  (π rad = 180°)
(Math.PI / 2) * (180 / Math.PI)  // 90   (π/2 rad = 90°)
(Math.PI / 4) * (180 / Math.PI)  // 45   (π/4 rad = 45°)

1. Reusable Helper Function

const toDegrees = rad => rad * (180 / Math.PI)

toDegrees(0)           // 0
toDegrees(Math.PI / 6) // 30
toDegrees(Math.PI / 4) // 45
toDegrees(Math.PI / 3) // 60
toDegrees(Math.PI / 2) // 90
toDegrees(Math.PI)     // 180
toDegrees(2 * Math.PI) // 360

2. Pre-Calculated Constant for Performance

In animation loops or high-frequency conversions, cache 180 / Math.PI to avoid repeated division.

const RAD_TO_DEG = 180 / Math.PI

function angleDisplay(radians) {
  return (radians * RAD_TO_DEG).toFixed(1) + '°'
}

angleDisplay(Math.PI / 4)  // '45.0°'
angleDisplay(Math.PI)      // '180.0°'

3. Converting atan2() Output

Math.atan2(y, x) returns the angle in radians between the positive x-axis and the point (x, y). Converting to degrees makes the result human-readable.

const toDegrees = rad => rad * (180 / Math.PI)

// Angle from origin to point (1, 1) — should be 45°
toDegrees(Math.atan2(1, 1))    // 45

// Angle from origin to point (-1, 0) — should be 180°
toDegrees(Math.atan2(0, -1))   // 180

// Angle from origin to point (0, -1) — should be -90°
toDegrees(Math.atan2(-1, 0))   // -90

This is one of the most common real-world uses — computing the angle of a drag gesture, joystick, or pointer relative to a center point.

4. Converting asin() and acos()

Math.asin() and Math.acos() return values in [-π/2, π/2] and [0, π] respectively. Convert for display.

const toDegrees = rad => rad * (180 / Math.PI)

toDegrees(Math.asin(0.5))    // 30    — arcsin(0.5) = 30°
toDegrees(Math.asin(1))      // 90    — arcsin(1)   = 90°
toDegrees(Math.acos(0.5))    // 60    — arccos(0.5) = 60°
toDegrees(Math.acos(0))      // 90    — arccos(0)   = 90°
toDegrees(Math.acos(-1))     // 180   — arccos(-1)  = 180°

5. Normalising Angles to 0–360

atan2 can return negative values. For a compass or rotation display, normalise to [0, 360).

const toDegrees = rad => rad * (180 / Math.PI)

function normaliseAngle(rad) {
  const deg = toDegrees(rad)
  return ((deg % 360) + 360) % 360
}

normaliseAngle(Math.atan2(-1, 0))   // 270  (was -90°)
normaliseAngle(Math.atan2(0, -1))   // 180
normaliseAngle(Math.atan2(1, 1))    // 45

The double-modulo trick ((deg % 360) + 360) % 360 handles both positive and negative inputs cleanly.

6. Displaying with toFixed()

For UI labels, round to a sensible number of decimal places using toFixed().

const toDegrees = rad => rad * (180 / Math.PI)

const angle = Math.atan2(3, 4)
toDegrees(angle)            // 36.86989764584402
toDegrees(angle).toFixed(1) // '36.9'
toDegrees(angle).toFixed(0) // '37'

// Parse back to number if needed for further math
parseFloat(toDegrees(angle).toFixed(2))  // 36.87

Use toFixed() for display strings, not for further arithmetic — it returns a string.

Best Practice Note:

Cache 180 / Math.PI as RAD_TO_DEG when converting frequently. Use toFixed(1) or toFixed(0) for degree labels in UI — raw floating-point output is rarely appropriate to show users. Normalise to [0, 360) when displaying compass bearings or rotation dials. For the inverse, multiply by Math.PI / 180 — see how to convert degrees to radians in JavaScript.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author