T
ToolPrime

Unit Conversion Cheat Sheet for Developers

Quick reference tables for common unit conversions: bytes, time, distance, weight, and temperature. Essential for developers working across systems.

TP
ToolPrime Team
4 min read

Developers frequently need to convert between units — bytes to megabytes for storage calculations, milliseconds to human-readable time for debugging, or metric to imperial for international projects. This cheat sheet covers the most common conversions with ready-to-use reference tables.

Bookmark this page or use the Unit Converter for instant calculations.

Digital Storage

Digital storage is measured in bytes, with larger units using either binary (powers of 1024) or decimal (powers of 1000) prefixes. The distinction matters: a “1 TB” hard drive holds 1,000,000,000,000 bytes (decimal), but your operating system reports it as 931 GB (binary).

Binary (IEC) Units

UnitBytesPractical Reference
1 KiB (Kibibyte)1,024A short text file
1 MiB (Mebibyte)1,048,576A high-quality photo
1 GiB (Gibibyte)1,073,741,824~20 minutes of HD video
1 TiB (Tebibyte)1,099,511,627,776~250 hours of HD video

Decimal (SI) Units

UnitBytesUsed By
1 KB (Kilobyte)1,000Network speeds, drive manufacturers
1 MB (Megabyte)1,000,000File downloads, email limits
1 GB (Gigabyte)1,000,000,000Mobile data plans, drive capacities
1 TB (Terabyte)1,000,000,000,000Cloud storage, hard drives

Quick Conversions

  • 1 GB = 1,024 MB (binary) or 1,000 MB (decimal)
  • 1 TB = 1,024 GB (binary) or 1,000 GB (decimal)
  • 1 MB = 8 Megabits (Mb) — important for network speeds
  • 100 Mbps internet = 12.5 MB/s actual download speed

Developer tip: When calculating file sizes in code, use binary units (1024). When displaying sizes to users, consider using decimal units (1000) to match expectations from drive manufacturers and network providers.

Time

Time conversions are constant sources of bugs in software. Off-by-one errors, timezone confusion, and inconsistent units cause more subtle issues than most developers realize.

Reference Table

FromToMultiplier
1 second1,000 millisecondsx 1,000
1 minute60 secondsx 60
1 hour3,600 secondsx 3,600
1 day86,400 secondsx 86,400
1 week604,800 secondsx 604,800
1 year31,536,000 secondsx 31,536,000 (approx)

Useful Constants for Code

1 second  = 1_000 ms
1 minute  = 60_000 ms
1 hour    = 3_600_000 ms
1 day     = 86_400_000 ms
1 week    = 604_800_000 ms

Common Timeout Values

Use CaseTypical Value
API request timeout5,000-30,000 ms
Database query timeout5,000-60,000 ms
Session timeout1,800,000 ms (30 min)
JWT token expiry3,600 s (1 hour)
Cache TTL (short)300 s (5 minutes)
Cache TTL (long)86,400 s (24 hours)

Use the Timestamp Converter to convert between Unix timestamps and human-readable dates when debugging time-related issues.

Length / Distance

Metric to Imperial

MetricImperialFactor
1 millimeter (mm)0.0394 inchesx 0.0394
1 centimeter (cm)0.3937 inchesx 0.3937
1 meter (m)3.2808 feetx 3.2808
1 kilometer (km)0.6214 milesx 0.6214

Imperial to Metric

ImperialMetricFactor
1 inch (in)2.54 cmx 2.54 (exact)
1 foot (ft)30.48 cmx 30.48
1 yard (yd)0.9144 mx 0.9144
1 mile (mi)1.6093 kmx 1.6093

Developer Reference

Screen ContextSize
1 CSS pixel1/96 inch (0.26 mm) at 96 DPI
iPhone screen width375-430 CSS pixels
Typical laptop1366-1920 CSS pixels
A4 paper210 x 297 mm (8.27 x 11.69 in)
US Letter216 x 279 mm (8.5 x 11 in)

Weight / Mass

Metric to Imperial

MetricImperialFactor
1 gram (g)0.0353 ozx 0.0353
1 kilogram (kg)2.2046 lbsx 2.2046
1 metric ton (t)2,204.6 lbsx 2,204.6

Imperial to Metric

ImperialMetricFactor
1 ounce (oz)28.3495 gx 28.3495
1 pound (lb)0.4536 kgx 0.4536

Quick Mental Math

  • kg to lbs: Double and add 10% (70 kg: 70 x 2 = 140, + 14 = 154 lbs; actual: 154.3)
  • lbs to kg: Halve and subtract 10% (150 lbs: 150 / 2 = 75, - 7.5 = 67.5 kg; actual: 68.0)

Temperature

Formulas

  • Celsius to Fahrenheit: F = (C x 9/5) + 32
  • Fahrenheit to Celsius: C = (F - 32) x 5/9
  • Celsius to Kelvin: K = C + 273.15

Key Reference Points

DescriptionCelsiusFahrenheitKelvin
Absolute zero-273.15-459.670
Water freezes032273.15
Room temperature20-2268-72293-295
Body temperature3798.6310.15
Water boils100212373.15

Quick Mental Math

  • C to F: Double and add 30 (gives approximate value; 20 C: 40 + 30 = 70 F; actual: 68 F)
  • F to C: Subtract 30 and halve (72 F: 42 / 2 = 21 C; actual: 22.2 C)

Volume (Cooking)

UnitMillilitersUS Cups
1 teaspoon (tsp)4.93 mL1/48 cup
1 tablespoon (tbsp)14.79 mL1/16 cup
1 fluid ounce (fl oz)29.57 mL1/8 cup
1 cup (US)236.59 mL1 cup
1 pint (US)473.18 mL2 cups
1 quart (US)946.35 mL4 cups
1 gallon (US)3,785.41 mL16 cups
1 liter1,000 mL4.23 cups

Note: UK/Imperial cups (284 mL) and Australian cups (250 mL) differ from US cups (237 mL). Always check which system a recipe uses.

CSS Units

For front-end developers, CSS units deserve their own reference:

UnitRelative ToCommon Use
pxViewportBorders, shadows, fixed elements
remRoot font size (default 16px)Font sizes, spacing, margins
emParent font sizeComponent-relative sizing
%Parent elementWidths, responsive layouts
vw1% of viewport widthFull-width elements
vh1% of viewport heightFull-height sections
chWidth of the “0” characterMax line lengths for readability

Common CSS Conversions (at 16px root)

remPixels
0.25rem4px
0.5rem8px
0.75rem12px
1rem16px
1.25rem20px
1.5rem24px
2rem32px
3rem48px
4rem64px

Using the Unit Converter

For conversions not covered in these tables, or when you need precise values with many decimal places, use the Unit Converter. It covers hundreds of unit combinations across length, weight, temperature, volume, area, speed, time, and digital storage.

Keep this cheat sheet handy for the quick lookups you do every day. For everything else, there is always a converter tool a click away.