Working on international projects? You'll inevitably need to convert between metric (used by most of the world) and imperial (used by the US, Liberia, and Myanmar). Here's a practical reference for developers.
The Two Systems
Metric (SI)
Based on powers of 10—clean and logical:
- Length: meter (m)
- Mass: gram (g), kilogram (kg)
- Volume: liter (L)
- Temperature: Celsius (°C)
Prefixes are consistent: kilo = 1000, centi = 1/100, milli = 1/1000
Imperial/US Customary
Based on... historical reasons:
- Length: inch, foot, yard, mile
- Mass: ounce, pound
- Volume: cup, pint, quart, gallon
- Temperature: Fahrenheit (°F)
Conversions within the system aren't intuitive: 12 inches = 1 foot, 5,280 feet = 1 mile.
Length Conversions
Quick Reference
| Metric |
Imperial |
Exact |
| 1 mm |
0.039 in |
|
| 1 cm |
0.394 in |
|
| 1 m |
3.281 ft |
|
| 1 m |
39.37 in |
|
| 1 km |
0.621 mi |
|
| 2.54 cm |
1 in |
exact |
| 30.48 cm |
1 ft |
exact |
| 1.609 km |
1 mi |
|
// Length conversions
const inchesToCm = (inches) => inches * 2.54;
const cmToInches = (cm) => cm / 2.54;
const feetToMeters = (feet) => feet * 0.3048;
const metersToFeet = (meters) => meters / 0.3048;
const milesToKm = (miles) => miles * 1.609344;
const kmToMiles = (km) => km / 1.609344;
Common Values
| Imperial |
Metric |
| 1 inch |
2.54 cm |
| 1 foot |
30.48 cm |
| 1 yard |
0.914 m |
| 1 mile |
1.609 km |
| 6 feet |
1.83 m |
| 100 yards |
91.4 m |
| 5K race |
3.1 miles |
| Marathon |
26.2 miles (42.2 km) |
Weight/Mass Conversions
Quick Reference
| Metric |
Imperial |
| 1 g |
0.035 oz |
| 28.35 g |
1 oz |
| 1 kg |
2.205 lb |
| 453.6 g |
1 lb |
// Weight conversions
const poundsToKg = (lb) => lb * 0.45359237;
const kgToPounds = (kg) => kg / 0.45359237;
const ouncesToGrams = (oz) => oz * 28.349523;
const gramsToOunces = (g) => g / 28.349523;
Common Values
| Imperial |
Metric |
| 1 ounce |
28.35 g |
| 1 pound |
453.6 g |
| 100 lb |
45.4 kg |
| 150 lb |
68 kg |
| 200 lb |
90.7 kg |
Volume Conversions
Quick Reference (US)
| Metric |
US |
| 1 mL |
0.034 fl oz |
| 29.57 mL |
1 fl oz |
| 1 L |
0.264 gal |
| 3.785 L |
1 gal |
Note: UK imperial volumes differ from US customary!
US vs UK Volumes
| Unit |
US |
UK |
| Fluid ounce |
29.57 mL |
28.41 mL |
| Pint |
473 mL |
568 mL |
| Gallon |
3.785 L |
4.546 L |
// Volume conversions (US)
const litersToGallons = (L) => L * 0.264172;
const gallonsToLiters = (gal) => gal * 3.78541;
const mlToFlOz = (ml) => ml * 0.033814;
const flOzToMl = (floz) => floz * 29.5735;
Common Values
| US |
Metric |
| 1 cup |
237 mL |
| 1 pint |
473 mL |
| 1 quart |
946 mL |
| 1 gallon |
3.79 L |
| 12 fl oz (can) |
355 mL |
| 2 liter bottle |
67.6 fl oz |
Temperature Conversions
// Temperature conversions
const celsiusToFahrenheit = (c) => (c * 9/5) + 32;
const fahrenheitToCelsius = (f) => (f - 32) * 5/9;
const celsiusToKelvin = (c) => c + 273.15;
const kelvinToCelsius = (k) => k - 273.15;
Reference Points
| Description |
°F |
°C |
| Absolute zero |
-459.67 |
-273.15 |
| Water freezes |
32 |
0 |
| Room temperature |
68-72 |
20-22 |
| Body temperature |
98.6 |
37 |
| Water boils |
212 |
100 |
Quick Mental Math
For rough Celsius to Fahrenheit:
Double it and add 30
20°C → (20 × 2) + 30 = 70°F (actual: 68°F)
30°C → (30 × 2) + 30 = 90°F (actual: 86°F)
For rough Fahrenheit to Celsius:
Subtract 30 and halve it
70°F → (70 - 30) / 2 = 20°C (actual: 21°C)
90°F → (90 - 30) / 2 = 30°C (actual: 32°C)
Speed Conversions
Quick Reference
| Metric |
Imperial |
| 1 km/h |
0.621 mph |
| 1.609 km/h |
1 mph |
| 1 m/s |
2.237 mph |
const kphToMph = (kph) => kph * 0.621371;
const mphToKph = (mph) => mph * 1.60934;
const msToMph = (ms) => ms * 2.23694;
const mphToMs = (mph) => mph / 2.23694;
Common Speeds
| mph |
km/h |
| 30 |
48 |
| 60 |
97 |
| 65 |
105 |
| 70 |
113 |
| 100 |
161 |
Area Conversions
Quick Reference
| Metric |
Imperial |
| 1 m² |
10.76 ft² |
| 1 hectare |
2.47 acres |
| 1 km² |
0.386 mi² |
| 1 ft² |
0.093 m² |
| 1 acre |
4,047 m² |
const sqMetersToSqFeet = (m2) => m2 * 10.7639;
const sqFeetToSqMeters = (ft2) => ft2 / 10.7639;
const hectaresToAcres = (ha) => ha * 2.47105;
const acresToHectares = (acres) => acres / 2.47105;
Complete Conversion Library
Here's a reusable JavaScript conversion library:
const conversions = {
length: {
mmToIn: (mm) => mm * 0.0393701,
inToMm: (inch) => inch * 25.4,
cmToIn: (cm) => cm * 0.393701,
inToCm: (inch) => inch * 2.54,
mToFt: (m) => m * 3.28084,
ftToM: (ft) => ft * 0.3048,
kmToMi: (km) => km * 0.621371,
miToKm: (mi) => mi * 1.60934
},
weight: {
gToOz: (g) => g * 0.035274,
ozToG: (oz) => oz * 28.3495,
kgToLb: (kg) => kg * 2.20462,
lbToKg: (lb) => lb * 0.453592
},
volume: {
mlToFlOz: (ml) => ml * 0.033814,
flOzToMl: (floz) => floz * 29.5735,
lToGal: (l) => l * 0.264172,
galToL: (gal) => gal * 3.78541
},
temperature: {
cToF: (c) => (c * 9/5) + 32,
fToC: (f) => (f - 32) * 5/9,
cToK: (c) => c + 273.15,
kToC: (k) => k - 273.15
},
speed: {
kphToMph: (kph) => kph * 0.621371,
mphToKph: (mph) => mph * 1.60934
}
};
Python Equivalent
class Converter:
# Length
@staticmethod
def cm_to_inches(cm): return cm / 2.54
@staticmethod
def inches_to_cm(inches): return inches * 2.54
@staticmethod
def km_to_miles(km): return km * 0.621371
@staticmethod
def miles_to_km(miles): return miles * 1.60934
# Weight
@staticmethod
def kg_to_pounds(kg): return kg * 2.20462
@staticmethod
def pounds_to_kg(lb): return lb * 0.453592
# Temperature
@staticmethod
def celsius_to_fahrenheit(c): return (c * 9/5) + 32
@staticmethod
def fahrenheit_to_celsius(f): return (f - 32) * 5/9
Tips for International Development
- Store in metric internally: Convert for display only
- Use locale settings: Detect user's preferred units
- Always show units: Never assume the user knows which system you're using
- Provide both: When possible, show both systems
- Be precise where it matters: Medical and scientific applications need accuracy
Summary
| Converting |
Multiply by |
| inches → cm |
2.54 |
| cm → inches |
0.3937 |
| miles → km |
1.609 |
| km → miles |
0.621 |
| pounds → kg |
0.454 |
| kg → pounds |
2.205 |
| gallons (US) → liters |
3.785 |
| liters → gallons (US) |
0.264 |
| °F → °C |
(°F - 32) × 5/9 |
| °C → °F |
(°C × 9/5) + 32 |
Need to convert units quickly? Try our Unit Converter!