The metric system, officially known as the International System of Units (SI), is the most widely used system of measurement globally. Its foundation is based on base-10, making conversions between units straightforward and logical. This calculator helps you navigate common conversions for length, mass, and temperature.
Length Conversions
Length is a fundamental physical quantity. The SI base unit for length is the meter (m). Other common metric units for length include kilometers (km), centimeters (cm), and millimeters (mm).
Key Conversion Factors:
1 kilometer (km) = 1000 meters (m)
1 meter (m) = 100 centimeters (cm)
1 meter (m) = 1000 millimeters (mm)
1 centimeter (cm) = 10 millimeters (mm)
This calculator also includes conversions to and from imperial units like inches (in), feet (ft), yards (yd), and miles (mi) for convenience.
1 meter ≈ 3.281 feet
1 inch = 0.0254 meters
Mass Conversions
Mass is a measure of the amount of matter in an object. The SI base unit for mass is the kilogram (kg), although the gram (g) is often used for smaller quantities. Common metric units include kilograms (kg), grams (g), and milligrams (mg).
Key Conversion Factors:
1 kilogram (kg) = 1000 grams (g)
1 gram (g) = 1000 milligrams (mg)
1 kilogram (kg) = 1,000,000 milligrams (mg)
Conversions to and from imperial units like pounds (lb) and ounces (oz) are also supported.
1 kilogram ≈ 2.205 pounds
1 pound ≈ 0.454 kilograms
Temperature Conversions
Temperature measures the degree of hotness or coldness of a substance. The SI derived unit for thermodynamic temperature is the Kelvin (K), but Celsius (°C) and Fahrenheit (°F) are more commonly used in everyday contexts.
Key Conversion Formulas:
Celsius to Fahrenheit: °F = (°C × 9/5) + 32
Fahrenheit to Celsius: °C = (°F – 32) × 5/9
Celsius to Kelvin: K = °C + 273.15
Kelvin to Celsius: °C = K – 273.15
Fahrenheit to Kelvin: K = (°F – 32) × 5/9 + 273.15
Understanding these conversions is crucial for science, engineering, cooking, and daily life, ensuring accuracy and consistency across different measurements.
function convertLength() {
var value = parseFloat(document.getElementById('lengthValue').value);
var fromUnit = document.getElementById('fromUnitLength').value;
var toUnit = document.getElementById('toUnitLength').value;
var resultValueElement = document.getElementById('convertedLengthValue');
var resultUnitElement = document.getElementById('convertedLengthUnit');
var resultContainer = document.getElementById('lengthResult');
if (isNaN(value)) {
alert("Please enter a valid number for the length value.");
return;
}
// Conversion factors relative to meters (base unit for length)
var factors = {
'm': 1,
'km': 1000,
'cm': 0.01,
'mm': 0.001,
'in': 0.0254,
'ft': 0.3048,
'yd': 0.9144,
'mi': 1609.34
};
// Convert input value to meters
var valueInMeters = value * factors[fromUnit];
// Convert meters to the target unit
var convertedValue = valueInMeters / factors[toUnit];
resultValueElement.innerText = convertedValue.toFixed(5); // Display with 5 decimal places
resultUnitElement.innerText = toUnit;
resultContainer.style.display = 'block';
}
function convertMass() {
var value = parseFloat(document.getElementById('massValue').value);
var fromUnit = document.getElementById('fromUnitMass').value;
var toUnit = document.getElementById('toUnitMass').value;
var resultValueElement = document.getElementById('convertedMassValue');
var resultUnitElement = document.getElementById('convertedMassUnit');
var resultContainer = document.getElementById('massResult');
if (isNaN(value)) {
alert("Please enter a valid number for the mass value.");
return;
}
// Conversion factors relative to kilograms (base unit for mass)
var factors = {
'kg': 1,
'g': 0.001,
'mg': 0.000001,
'lb': 0.453592,
'oz': 0.0283495
};
// Convert input value to kilograms
var valueInKg = value * factors[fromUnit];
// Convert kilograms to the target unit
var convertedValue = valueInKg / factors[toUnit];
resultValueElement.innerText = convertedValue.toFixed(5); // Display with 5 decimal places
resultUnitElement.innerText = toUnit;
resultContainer.style.display = 'block';
}
function convertTemperature() {
var value = parseFloat(document.getElementById('tempValue').value);
var fromUnit = document.getElementById('fromUnitTemp').value;
var toUnit = document.getElementById('toUnitTemp').value;
var resultValueElement = document.getElementById('convertedTempValue');
var resultUnitElement = document.getElementById('convertedTempUnit');
var resultContainer = document.getElementById('tempResult');
if (isNaN(value)) {
alert("Please enter a valid number for the temperature value.");
return;
}
var valueInCelsius = 0;
// Convert input to Celsius first
if (fromUnit === 'c') {
valueInCelsius = value;
} else if (fromUnit === 'f') {
valueInCelsius = (value – 32) * 5 / 9;
} else if (fromUnit === 'k') {
valueInCelsius = value – 273.15;
}
var convertedValue = 0;
// Convert from Celsius to the target unit
if (toUnit === 'c') {
convertedValue = valueInCelsius;
} else if (toUnit === 'f') {
convertedValue = (valueInCelsius * 9 / 5) + 32;
} else if (toUnit === 'k') {
convertedValue = valueInCelsius + 273.15;
}
resultValueElement.innerText = convertedValue.toFixed(5); // Display with 5 decimal places
resultUnitElement.innerText = toUnit === 'c' ? '°C' : (toUnit === 'f' ? '°F' : 'K');
resultContainer.style.display = 'block';
}