Unit Converter
Convert between different measurement units. Supports length, weight, temperature, area, volume, speed, time, and data units.
When to Use
- Convert between metric and imperial units
- Calculate unit equivalencies
- Work with different measurement systems
- Convert digital storage sizes
Quick Start
Basic Conversions
python3 scripts/unit-convert.py 100 cm m
# Output: 100 cm = 1 m
python3 scripts/unit-convert.py 10 kg lb
# Output: 10 kg = 22.05 lb
python3 scripts/unit-convert.py 25 C F
# Output: 25 C = 77 F
List Units
python3 scripts/unit-convert.py list length
# Shows all length units
Show Categories
python3 scripts/unit-convert.py categories
Commands
<value> <from_unit> <to_unit>
Convert between units.
Examples:
# Length
python3 scripts/unit-convert.py 100 cm m
python3 scripts/unit-convert.py 5 ft cm
python3 scripts/unit-convert.py 1 mi km
# Weight
python3 scripts/unit-convert.py 10 kg lb
python3 scripts/unit-convert.py 1000 g kg
python3 scripts/unit-convert.py 16 oz lb
# Temperature
python3 scripts/unit-convert.py 25 C F
python3 scripts/unit-convert.py 98.6 F C
python3 scripts/unit-convert.py 300 K C
# Area
python3 scripts/unit-convert.py 100 m2 ft2
python3 scripts/unit-convert.py 1 acre m2
# Volume
python3 scripts/unit-convert.py 1000 ml l
python3 scripts/unit-convert.py 1 gal l
# Speed
python3 scripts/unit-convert.py 100 km/h mph
python3 scripts/unit-convert.py 10 m/s km/h
# Time
python3 scripts/unit-convert.py 3600 s h
python3 scripts/unit-convert.py 7 day h
# Data
python3 scripts/unit-convert.py 1024 B KB
python3 scripts/unit-convert.py 1 GB MB
list <category>
List all units in a category.
Examples:
python3 scripts/unit-convert.py list length
python3 scripts/unit-convert.py list weight
python3 scripts/unit-convert.py list temperature
categories
Show all supported categories.
python3 scripts/unit-convert.py categories
help <category>
Show help for a specific category.
python3 scripts/unit-convert.py help temperature
python3 scripts/unit-convert.py help length
Supported Categories
Length
- Metric: mm, cm, m, km
- Imperial: in, ft, yd, mi, inch, foot, yard, mile
Weight
- Metric: mg, g, kg, t (tonne)
- Imperial: oz, lb, stone, ounce, pound
Temperature
- C - Celsius
- F - Fahrenheit
- K - Kelvin
Area
- Metric: mm², cm², m², km²
- Imperial: in², ft², yd², acre, mi²
Volume
- Metric: ml, l, kl
- Imperial: fl oz, cup, pt, qt, gal
Speed
- Metric: m/s, km/h
- Imperial: ft/s, mph
- Nautical: knot
Time
- Short: ms, s, min
- Long: h, day, week, year
Data
- Binary: B, KB, MB, GB, TB, PB
- (Uses 1024-based conversion)
Unit Aliases
The converter accepts common aliases:
| Standard |
Aliases |
| in |
inch, inches |
| ft |
foot, feet |
| yd |
yard, yards |
| mi |
mile, miles |
| oz |
ounce, ounces |
| lb |
pound, pounds |
| pt |
pint, pints |
| qt |
quart, quarts |
| gal |
gallon, gallons |
| ml |
milliliter, milliliters |
| l |
liter, liters |
| kl |
kiloliter, kiloliters |
| h |
hour, hours |
| min |
minute, minutes |
| s |
second, seconds |
| ms |
millisecond, milliseconds |
Examples
Everyday Conversions
# Height conversions
python3 scripts/unit-convert.py 180 cm ft
python3 scripts/unit-convert.py 6 ft cm
# Weight conversions
python3 scripts/unit-convert.py 70 kg lb
python3 scripts/unit-convert.py 150 lb kg
# Temperature
python3 scripts/unit-convert.py 32 F C
python3 scripts/unit-convert.py 100 C F
# Area (room size)
python3 scripts/unit-convert.py 100 m2 ft2
python3 scripts/unit-convert.py 1000 ft2 m2
Cooking & Recipes
# Volume conversions
python3 scripts/unit-convert.py 1 cup ml
python3 scripts/unit-convert.py 250 ml cup
python3 scripts/unit-convert.py 1 gal l
# Weight conversions
python3 scripts/unit-convert.py 500 g lb
python3 scripts/unit-convert.py 1 lb g
Travel & Distance
# Distance
python3 scripts/unit-convert.py 100 km mi
python3 scripts/unit-convert.py 50 mi km
# Speed limits
python3 scripts/unit-convert.py 60 mph km/h
python3 scripts/unit-convert.py 100 km/h mph
Digital Storage
# File sizes
python3 scripts/unit-convert.py 1 GB MB
python3 scripts/unit-convert.py 1024 KB MB
python3 scripts/unit-convert.py 1 TB GB
Science & Engineering
# Precise measurements
python3 scripts/unit-convert.py 25.4 mm in
python3 scripts/unit-convert.py 1000 mg g
# Time calculations
python3 scripts/unit-convert.py 365 day h
python3 scripts/unit-convert.py 86400 s day
Tips
- Use the
list command to see all available units for a category
- Temperature units are case-sensitive (C, F, K)
- For compound units like m/s, use the slash notation
- The converter handles both short and long unit names
- Results are formatted for readability
Troubleshooting
"Cannot convert" error:
- Check unit spelling
- Ensure units are from the same category (e.g., don't convert length to weight)
- Use
list command to see available units
Unexpected results:
- Temperature conversions use standard formulas
- Data conversions use 1024-based (binary) units
- Double-check unit case sensitivity
Notes
- Temperature conversions use standard formulas
- Data conversions use binary (1024-based) units
- All other conversions use decimal (1000-based) units
- Results are automatically formatted for readability
1---2name: unit-convert3description: Comprehensive unit converter for length, weight, temperature, area, volume, speed, time, and data. Use when: (1) converting between measurement units, (2) calculating unit equivalencies, (3) working with different measurement systems, or (4) any unit conversion needs. Supports metric, imperial, and digital units.4---5
6# Unit Converter
7
8Convert between different measurement units. Supports length, weight, temperature, area, volume, speed, time, and data units.
9
10## When to Use
11
12- Convert between metric and imperial units
13- Calculate unit equivalencies
14- Work with different measurement systems
15- Convert digital storage sizes
16
17## Quick Start
18
19### Basic Conversions
20```bash
21python3 scripts/unit-convert.py 100 cm m
22# Output: 100 cm = 1 m
23
24python3 scripts/unit-convert.py 10 kg lb
25# Output: 10 kg = 22.05 lb
26
27python3 scripts/unit-convert.py 25 C F
28# Output: 25 C = 77 F
29```
30
31### List Units
32```bash
33python3 scripts/unit-convert.py list length
34# Shows all length units
35```
36
37### Show Categories
38```bash
39python3 scripts/unit-convert.py categories
40```
41
42## Commands
43
44### `<value> <from_unit> <to_unit>`
45Convert between units.
46
47**Examples:**
48```bash
49# Length
50python3 scripts/unit-convert.py 100 cm m
51python3 scripts/unit-convert.py 5 ft cm
52python3 scripts/unit-convert.py 1 mi km
53
54# Weight
55python3 scripts/unit-convert.py 10 kg lb
56python3 scripts/unit-convert.py 1000 g kg
57python3 scripts/unit-convert.py 16 oz lb
58
59# Temperature
60python3 scripts/unit-convert.py 25 C F
61python3 scripts/unit-convert.py 98.6 F C
62python3 scripts/unit-convert.py 300 K C
63
64# Area
65python3 scripts/unit-convert.py 100 m2 ft2
66python3 scripts/unit-convert.py 1 acre m2
67
68# Volume
69python3 scripts/unit-convert.py 1000 ml l
70python3 scripts/unit-convert.py 1 gal l
71
72# Speed
73python3 scripts/unit-convert.py 100 km/h mph
74python3 scripts/unit-convert.py 10 m/s km/h
75
76# Time
77python3 scripts/unit-convert.py 3600 s h
78python3 scripts/unit-convert.py 7 day h
79
80# Data
81python3 scripts/unit-convert.py 1024 B KB
82python3 scripts/unit-convert.py 1 GB MB
83```
84
85### `list <category>`
86List all units in a category.
87
88**Examples:**
89```bash
90python3 scripts/unit-convert.py list length
91python3 scripts/unit-convert.py list weight
92python3 scripts/unit-convert.py list temperature
93```
94
95### `categories`
96Show all supported categories.
97
98```bash
99python3 scripts/unit-convert.py categories
100```
101
102### `help <category>`
103Show help for a specific category.
104
105```bash
106python3 scripts/unit-convert.py help temperature
107python3 scripts/unit-convert.py help length
108```
109
110## Supported Categories
111
112### Length
113- **Metric**: mm, cm, m, km
114- **Imperial**: in, ft, yd, mi, inch, foot, yard, mile
115
116### Weight
117- **Metric**: mg, g, kg, t (tonne)
118- **Imperial**: oz, lb, stone, ounce, pound
119
120### Temperature
121- **C** - Celsius
122- **F** - Fahrenheit
123- **K** - Kelvin
124
125### Area
126- **Metric**: mm², cm², m², km²
127- **Imperial**: in², ft², yd², acre, mi²
128
129### Volume
130- **Metric**: ml, l, kl
131- **Imperial**: fl oz, cup, pt, qt, gal
132
133### Speed
134- **Metric**: m/s, km/h
135- **Imperial**: ft/s, mph
136- **Nautical**: knot
137
138### Time
139- **Short**: ms, s, min
140- **Long**: h, day, week, year
141
142### Data
143- **Binary**: B, KB, MB, GB, TB, PB
144- (Uses 1024-based conversion)
145
146## Unit Aliases
147
148The converter accepts common aliases:
149
150| Standard | Aliases |
151|----------|---------|
152| in | inch, inches |
153| ft | foot, feet |
154| yd | yard, yards |
155| mi | mile, miles |
156| oz | ounce, ounces |
157| lb | pound, pounds |
158| pt | pint, pints |
159| qt | quart, quarts |
160| gal | gallon, gallons |
161| ml | milliliter, milliliters |
162| l | liter, liters |
163| kl | kiloliter, kiloliters |
164| h | hour, hours |
165| min | minute, minutes |
166| s | second, seconds |
167| ms | millisecond, milliseconds |
168
169## Examples
170
171### Everyday Conversions
172```bash
173# Height conversions
174python3 scripts/unit-convert.py 180 cm ft
175python3 scripts/unit-convert.py 6 ft cm
176
177# Weight conversions
178python3 scripts/unit-convert.py 70 kg lb
179python3 scripts/unit-convert.py 150 lb kg
180
181# Temperature
182python3 scripts/unit-convert.py 32 F C
183python3 scripts/unit-convert.py 100 C F
184
185# Area (room size)
186python3 scripts/unit-convert.py 100 m2 ft2
187python3 scripts/unit-convert.py 1000 ft2 m2
188```
189
190### Cooking & Recipes
191```bash
192# Volume conversions
193python3 scripts/unit-convert.py 1 cup ml
194python3 scripts/unit-convert.py 250 ml cup
195python3 scripts/unit-convert.py 1 gal l
196
197# Weight conversions
198python3 scripts/unit-convert.py 500 g lb
199python3 scripts/unit-convert.py 1 lb g
200```
201
202### Travel & Distance
203```bash
204# Distance
205python3 scripts/unit-convert.py 100 km mi
206python3 scripts/unit-convert.py 50 mi km
207
208# Speed limits
209python3 scripts/unit-convert.py 60 mph km/h
210python3 scripts/unit-convert.py 100 km/h mph
211```
212
213### Digital Storage
214```bash
215# File sizes
216python3 scripts/unit-convert.py 1 GB MB
217python3 scripts/unit-convert.py 1024 KB MB
218python3 scripts/unit-convert.py 1 TB GB
219```
220
221### Science & Engineering
222```bash
223# Precise measurements
224python3 scripts/unit-convert.py 25.4 mm in
225python3 scripts/unit-convert.py 1000 mg g
226
227# Time calculations
228python3 scripts/unit-convert.py 365 day h
229python3 scripts/unit-convert.py 86400 s day
230```
231
232## Tips
233
234- Use the `list` command to see all available units for a category
235- Temperature units are case-sensitive (C, F, K)
236- For compound units like m/s, use the slash notation
237- The converter handles both short and long unit names
238- Results are formatted for readability
239
240## Troubleshooting
241
242**"Cannot convert" error:**
243- Check unit spelling
244- Ensure units are from the same category (e.g., don't convert length to weight)
245- Use `list` command to see available units
246
247**Unexpected results:**
248- Temperature conversions use standard formulas
249- Data conversions use 1024-based (binary) units
250- Double-check unit case sensitivity
251
252## Notes
253
254- Temperature conversions use standard formulas
255- Data conversions use binary (1024-based) units
256- All other conversions use decimal (1000-based) units
257- Results are automatically formatted for readability