You write Math.sin(90) expecting 1 and get 0.894. You enter =COS(60) in a spreadsheet expecting 0.5 and get -0.952. Nothing is broken: the function wanted radians and you gave it degrees. It is one of the most common angle bugs in programming and spreadsheet work, and it hides well because the wrong answers still look like plausible numbers.
This guide explains why software uses radians, shows the one-line conversion in the languages and tools you are most likely to use, and gives you quick checks to catch unit mistakes before they reach production or a client report.
Why functions expect radians
A radian measures an angle by arc length: one radian is the angle at which the arc is as long as the radius. A full circle is 2π radians, which equals 360°. Radians make the calculus of trigonometric functions clean; for example, the derivative of sin(x) is cos(x) only when x is in radians. So maths libraries, following the mathematics, define their trig functions in radians.
The conversion is:
radians = degrees × π ÷ 180
| Degrees | Radians (exact) | Radians (decimal) |
|---|---|---|
| 1° | π/180 | 0.017453 |
| 15° | π/12 | 0.261799 |
| 30° | π/6 | 0.523599 |
| 45° | π/4 | 0.785398 |
| 60° | π/3 | 1.047198 |
| 90° | π/2 | 1.570796 |
| 180° | π | 3.141593 |
| 270° | 3π/2 | 4.712389 |
| 360° | 2π | 6.283185 |
The conversion in common languages and tools
JavaScript and TypeScript
const toRadians = (deg) => (deg * Math.PI) / 180;
Math.sin(toRadians(30)); // 0.49999999999999994
There is no built-in helper in the standard Math object, so define one and use it everywhere.
Python
import math
math.sin(math.radians(30)) # 0.49999999999999994
NumPy provides numpy.radians and numpy.deg2rad, which work on whole arrays.
Excel and Google Sheets
=SIN(RADIANS(30)) → 0.5
=SIN(A2*PI()/180) → same thing
RADIANS() and DEGREES() exist in both spreadsheet apps.
SQL
Many databases, including MySQL and PostgreSQL, provide RADIANS() and DEGREES() functions. This matters for distance calculations between latitude and longitude, where coordinates are stored in degrees but the formula needs radians.
A worked example: latitude and longitude
The haversine formula for the distance between two points on a sphere is a classic place for this bug. Latitude and longitude are stored in degrees, but every SIN and COS in the formula needs radians. In JavaScript the first lines usually look like this:
const R = 6371; // mean Earth radius in km
const dLat = toRadians(lat2 - lat1);
const dLon = toRadians(lon2 - lon1);
const a = Math.sin(dLat / 2) ** 2 +
Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) * Math.sin(dLon / 2) ** 2;
const km = 2 * R * Math.asin(Math.sqrt(a));
Forget a single toRadians call and the result is still a number, just a wrong one. Testing with two points a known distance apart catches it immediately.
CSS
CSS is forgiving: rotate() accepts deg, rad, grad and turn units directly, so rotate(45deg) and rotate(0.785398rad) are equivalent. You only need to convert when you calculate an angle in JavaScript and pass a unitless number somewhere that expects radians.
Convert degrees to radians with our tool
When you need a specific value, for a constant in code, a unit test or a spreadsheet check, the Degrees to Radians Converter gives it instantly.
- Open the Degrees to Radians Converter. The first box is labelled Degrees (°).
- Type the angle, for example
37.5. The Radians (rad) box shows about 0.6544985. - Use the copy button beside the result line to paste the value into your code or test.
- Check the Formula line for the exact multiplier.
- The "in other units" list also shows gradians and arcminutes, which is handy for surveying or astronomy data.
- To check a radian value coming out of your program, type it into the radians box, or press Swap units. The Radians to Degrees Converter has its own guide on reading radian results.
Other ways to convert
- In code, always. For runtime values, convert with the language's built-in function or a small helper; don't hard-code a rounded constant like 0.0175.
- A scientific calculator in degree mode lets you evaluate sin(30°) directly. The Scientific Calculator has a DEG/RAD switch; our guide on using a scientific calculator covers the modes.
- Exact fractions. For textbook angles, divide by 180 and simplify: 150° is 150/180 = 5/6, so 5π/6.
Use the converter when you want a verified number to compare against, for example when writing test expectations.
Spotting angle-unit bugs
Sanity-check with known values
Test your function with 0°, 30°, 90° and 180°. If sin of 90 is not 1 (within floating-point error), something is wrong with the units.
| Call | Wrong (degrees passed) | Right (radians passed) |
|---|---|---|
| sin(90) | 0.894 | sin(π/2) = 1 |
| cos(60) | -0.952 | cos(π/3) = 0.5 |
| tan(45) | 1.620 | tan(π/4) = 1 |
Name your variables with units
headingDeg and headingRad make mismatches obvious in code review. A plain angle does not.
Expect tiny floating-point errors
Math.cos(Math.PI / 2) returns about 6.1e-17, not zero, because π cannot be stored exactly. Compare with a tolerance rather than exact equality.
Convert once, at the boundary
Accept degrees from users and config files, convert to radians as soon as the value enters your maths code, and convert back only for display. Converting back and forth repeatedly invites double conversion.
Frequently asked questions
Why does Math.sin(90) return 0.894?
Math.sin expects radians, so it calculates the sine of 90 radians, not 90°. Convert first: Math.sin(90 * Math.PI / 180) returns 1.
What is the formula for degrees to radians?
Multiply by π and divide by 180. For example, 60° × π/180 = π/3 ≈ 1.0472.
How do I use degrees in Excel's SIN function?
Wrap the angle in RADIANS(): =SIN(RADIANS(30)) returns 0.5.
Does CSS need radians?
No. CSS rotation functions accept degrees with the deg unit, as well as rad, grad and turn.
What is 1 degree in radians?
1° is π/180, about 0.0174533 radians.