Skip to content
Math Notes Documentation
Open Math Notes

Units & measures

Convert between units with to, in or as, name what you are measuring to convert across dimensions, and write rates naturally.

Unit conversion#

1cm to m
returns 0.01 m
2h to s
returns 7,200 s
5km to m
returns 5,000 m
30 degC to degF
returns 86 degF
100 lb in kg
returns 45.359… kg

A length, mass or volume written in two units is their sum, in the smaller unit, and min and sec are the minute and the second wherever a unit goes.

6 ft 2 in
returns 74 inch
1 m 80 cm
returns 180 cm
1 h to min
returns 60 minutes

CSS units are supported too, so you can check a layout:

1 cm in px
returns 37.795… px
2 em in px
returns 32 px

Areas and volumes can be written in words: 20 sq cm, 30 square inches, 5 m squared, 3 ft cubed, 11 sqm, 11 cbm or with ² and ³ (10 m²). They read as cm^2, inches^2, m^2, and so on.

Measurement system#

Cooking volume units follow the measurement system in Settings → Measurement system — Metric (default), US customary or Imperial. It sets cup to 250, 236.6 or 284.1 ml respectively, along with tsp, tbsp, fl oz, pint, quart and gallon.

Cooking & measures#

Convert between dimensions by naming what you are measuring. The subject is free-form and optional: a known ingredient uses its density, a fuel its energy density, media their bitrate, and anything else a default (water). Write it before to/in.

300g butter in cups
1.317… cups
2 cups flour in grams
265 grams
1 cup sugar in grams
211.25 grams
300g in cups
1.2 cups (subject optional)
300g feathers in cups
1.2 cups (any subject works)
1 l petrol in kWh
9.5 kWh
2 hours 4k video in GB
14.4 GB

Rates#

A rate is one unit per another. mathjs does the arithmetic; these phrases make rates easy to write. per, a, an, at and for are all understood.

90 km / 3 day
30 km/day
30 hours at 10 km/hour
300 km
100 km at 10 km/hour
10 hours
24 km a day for a year
8,766 km
time to upload 3 GB at 10 MB/s
5 min

The verb is optional.

time to 100 km at 50 km/h
returns 2 hours
5 km in 25 min
05:00/km

Two units of the same kind named with per, a or an stay a rate: 8 hours a day is 8 hours/day, 8 hours per day for a week is 56 hours, and work * 22 days after work = 8 hours a day is 176 hours. A plain / is a ratio (3 hours / day is 0.125).

Custom units#

Define your own unit with unit <name> = <amount>. It then behaves like a built-in one: the plural works, it converts to the units it was defined from, and it merges with them. Change the definition and every use follows. The plural of the last word is generated in the usual English ways (box/boxes, bus/buses, leaf/leaves, potato/potatoes) and ão becomes ões or ães; for any other plural, use the singular.

unit widget = 3.5 kg
2 widgets
2 widgets
unit widget = 3.5 kg
2 widgets in kg
7 kg

A name may contain several words or accents, and a unit can be built from another.

unit monthly rent = 1500
2 monthly rents
3,000
unit widget = 3.5 kg
unit box = 12 widgets
2 boxes in kg
84 kg

Definitions are scoped to the sheet that contains them, so removing the line removes the unit. unit and total are reserved words.

The unit rule#

Units only combine in shapes that mean something. kg L, BRL hour, h^2 and m^0.5 are reported as errors rather than as strange combined units. Money only forms ratios (USD/hour, USD/km), so use a rate when you want to convert a currency across time or distance.

Unit reference#

Dimension Units
Length meter (m), inch (in), foot (ft), yard (yd), mile (mi), link (li), rod (rd), chain (ch), nautical mile (nmi), fathom, furlong, lightyear (ly), angstrom, mil
Surface area m2, sqin, sqft, sqyd, sqmi, sqrd, sqch, sqmil, acre, hectare
Volume m3, litre (l, L, lt, liter), cc, cuin, cuft, cuyd, teaspoon, tablespoon
Liquid volume minim, fluiddram (fldr), fluidounce (floz), gill (gi), cup (cp), pint (pt), quart (qt), gallon (gal), beerbarrel (bbl), oilbarrel (obl), hogshead, drop (gtt)
Angles rad (radian), deg (degree), grad (gradian), cycle, arcsec (arcsecond), arcmin (arcminute)
Time second (s), minute (min), hour (h), day, week, month, year, decade, century, millennium
Speed knot (kn)
Frequency hertz (Hz)
Mass gram (g), tonne, ton, grain (gr), dram (dr), ounce (oz), poundmass (lbm, lb, lbs), hundredweight (cwt), carat (ct), stick (4 oz), stone
Electric current ampere (A)
Temperature kelvin (K), celsius (degC), fahrenheit (degF), rankine (degR)
Amount of substance mole (mol)
Luminous intensity candela (cd)
Force newton (N), dyne (dyn), poundforce (lbf), kip
Energy joule (J), erg, Wh, BTU, electronvolt (eV)
Power watt (W), hp
Pressure Pa, psi, atm, torr, bar, mmHg, mmH2O, cmH2O
Electricity & magnetism coulomb (C), volt (V), ohm, farad (F), weber (Wb), tesla (T), henry (H), siemens (S)
Binary bits (b), bytes (B)

See the mathjs units reference for the full list. Time and temperature units can also appear in dates and timespans.