The {{convert}} plugin is an implementation of the Wikipedia template of the same name, and can be used in much the same way to convert units in one measurement to another, as in miles to kilometres for instance.

Examples and parameters

The plugin is invoked by inserting {{convert|some arguments}} into the text of an article. It accepts an amount in one unit of measurement and converts it to another, inserting the formatted result into the body of the article. {{convert}} takes two mandatory parameters, separated by the “|” character: the quantity to be converted and the code for the units of that quantity; all other parameters are optional.

Supported units and their codes are given in the table at the end of this section.

Units to convert

  • {{convert|15|km|mi}} → 15 kilometres (9 mi)

The output unit of measurement can usually be omitted, as each input unit of measurement has an associated measurement to be converted to. In the case of kilometres the default is miles, but that can be overridden and specified explicitly as above:

  • {{convert|15|km}} → 15 kilometres (9 mi)

Unit name or abbreviation

By default, the first quantity shows the full name of the unit, the second shows the symbol (or abbreviation):

  • {{convert|1|lb}} → 1 pound (0.45 kg)

Using |abbr=on results in the input unit of measurement being abbreviated:

  • {{convert|1|lb|abbr=on}} → 1 lb (0.45 kg)

Adjective: a 10-mile distance

Use |adj=on to produce the adjectival (hyphenated) form:

  • A {{convert|10|mi|adj=on}} distance → A 10-mile (16 km) distance.

The output is hyphenated only if the input unit of measurement is not abbreviated:

  • {{convert|10|mi|abbr=on|adj=on}} → 10 mi (16 km)

Rounding

By default the number of decimal places in the output will be the same as that of the input:

  • {{convert|10.5|km}} → 10.5 kilometres (6.5 mi)

This default behaviour can be overridden by using the |r parameter to specify the required number of decimal places:

  • {{convert|10.5|km|r=0}} → 10.5 kilometres (7 mi)
  • {{convert|10.5|km|r=2}} → 10.5 kilometres (6.52 mi)

Spell out numbers: ten miles

To display a number in words use |spell=in:

  • {{convert|100|mi|spell=in}} → one hundred miles (161 km)

If the output from {{convert}} begins a sentence as in “Twenty-five miles (40 km) down the road …”, and |spell=in has been set, then the leading character can be capitalised with |sentence=on:

  • {{convert|25|mi|spell=in|sentence=on}} → Twenty-five miles (40 km)

Units

Conversion can only be carried out between units of the same type, e.g. length or area. It would be meaningless, for instance, to attempt to convert between degrees celsius and kilograms.

SystemUnitCodeAbbreviationDefault conversion
Lengths
SImillimetremmmmmm => in
centimetrecmcmcm => in
metremmm => ft
kilometrekmkmkm => mi
Imperialinchininin => cm
footftftft => m
yardydydyd => m
milemimimi => km
fathomfathomfathomfathom => m
furlongfurlongfurlongfurlong => m
Area
SIsquare metresqmm2sqm => sqft
square kilometresqkmkm2sqkm => sqmi
non-SI metrichectarehahaha => acre
Imperialsquare footsqftft2sqft => sqm
square yardsqydyd2sqyd => sqm
square milesqmimi2sqmi => sqkm
acreacreacreacre => ha
Weight
SIkilogramkgkgkg=>lb
Imperialpoundlblblb=>kg
Temperature
SIcelsiusC°CC => F
ImperialfahrenheitF°FF => C
Speed
SIkilometres per hourkm/hkm/hkm/h = > mph
Imperialmiles per hourmphmphmph = > km/h
Volume
SIlitrelLl => impgal
ImperialgallonimpgalGalimpgal => l