JavaScript Celsius to Fahrenheit and Back Conversion Functions

December 2025

These are the JavaScript functions I use to convert back and forth between Celsius to Fahrenheit:

JavaScript
function c2f(c) {
  return (c * 9/5) + 32;
}
JavaScript
function f2c(f) {
  return (f - 32) * 5/9;
}

You can see the output in the console.

JavaScript
console.log(c2f(30));

console.log(f2c(32));
end of line