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.

Units to convert

  • {{convert|1000|acre|sqkm}} → 1000 acres (4 km2)

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

  • {{convert|1000|acre}} → 1000 acres (405 ha)

Unit name or abbreviation in output

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


Conversions 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.

Length

SystemUnitCodeAbbreviationDefault conversion
SImillimetremmmmmm => in
centimetrecmcmcm => in
metremmm => ft
kilometrekmkmkm => mi
Imperialinchininin => cm
footftftft => m
yardydydyd => m
milemimimi => km
fathomfathomfathomfathom => m
furlongfurlongfurlongfurlong=>m

Area

SystemUnitCodeAbbreviationDefault conversion
SIsquare metresqmm2sqm => sqft
square kilometresqkmkm2sqkm => sqmi
non-SI metrichectarehahaha => acre
Imperialsquare footsqftft2sqft => sqm
square yardsqydyd2sqyd => sqm
square milesqmimi2sqmi => sqkm
acreacreacreacre => ha

Weight

SystemUnitCodeAbbreviationDefault conversion
SIgramggg => oz
kilogramkgkgkg => lb
Imperialounceozozoz => g
poundlblblb => kg
hundredweightcwtcwtcwt => kg

Speed

SystemUnitCodeAbbreviationDefault conversion
SIkilometres per hourkm/hkm/hkm/h => mph
Imperialmiles per hourmphmphmph => km/h

Volume

SystemUnitCodeAbbreviationDefault conversion
SIlitrelLl => impgal
cubic centimetrecccccc => cuin
cubic metrecumm3cum => cuft
Imperialpintptptpt => l
gallonimpgalGalimpgal => l
cubic inchcuinin3cuin => cc
cubic footcuftft3cuft => cum