Template:Convert/doc

From PsychonautWiki
Jump to navigation Jump to search

Usage

This template shows measurement quantities as primary and converted secondary units (or ranges), with optional rounding, wikilinks, abbreviation, or US spellings, and various separators including:  parentheses "( )", "or", hyphens, comma, "to" or dashes. It can help users by calculating correct conversions from one unit of measurement to another, particularly for more complex units. It's also useful by making the text adhere to the Manual of Style.

Styles include: distance "Template:Convert" and "Template:Convert"; temperature "Template:Convert"; mass "Template:Convert" or "Template:Convert"; etc. For units see: Convert/list of units.

Options include:  lk=in, abbr=on, abbr=off, sp=us, adj=on, adj=mid, disp=x, disp=table and sortable=on (explained below). By default, output is rounded to match the precision of input; alternatives include: sigfig=3 or using the end parameter, such as "|1" to show tenths or "|-2" to show full 100's, etc.

Single value:

{{convert|value|in_unit|out_unit|round_to|...}}

Range of 2 values, or set of 3 or 4 (see below for list of range options):

{{convert|val1|range|val2 |in_unit|out_unit|round_to|...}}
{{convert/3 |val1|range|val2|words|val3|in_unit|out_unit|round_to|...}}
{{convert/4|val1|words|val2|words|val3|words|val4|in_unit|out_unit|...}}
  • Optional parameters, in examples below, allow abbreviated units (abbr=on), or U.S. spellings (sp=us for meter), or hyphenation (adj=on), etc.
  • This template may in some cases directly convert to other base units, for example {{convert|29.8|km/s|mi/h}} will directly convert the km/s to mph, as in Template:Convert.
  • For this template many levels of substitution are possible, hence doing this fully, step by step, is cumbersome. Use Special:ExpandTemplates instead.
  • The template provides some dimensional analysis to check for compatible units. The user should be careful that input and output units are compatible. Do not, for example, attempt to convert barrels to tonnes (but see {{bbl to t}}). Also beware of units with similar names; the code oz, for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces. Note also that the code lb gives pounds mass, for pounds force use lbf.
  • This documentation page tends to lag behind in terms of what the template can do. For more details, see the talk page and its archives.

Examples

Single value

Input Displays as
{{convert|3.21|kg|lb}} Template:Convert
{{convert|3.21|kg|lb|0}} Template:Convert
{{convert|10|kg|lb|disp=or}} Template:Convert
{{convert|6|ft|5|in|m}} Template:Convert
{{convert|10|mi}} Template:Convert
{{convert|100|mpgus}} Template:Convert
{{convert|120|km/h}} Template:Convert
{{convert|18|°C|°F}} Template:Convert
{{convert|-15|C|F}} Template:Convert
{{convert|9|e6USgal|abbr=off}} Template:Convert
The "e6" scales the input to millions; the "abbr=off" yields the "mega" in the output.
Scaling is only available for Single value conversions. Not all units are supported.
{{convert|1250|sqft|m2|lk=in|sigfig=2}} Template:Convert
Note 'lk=in' links only the input unit. This example is for illustration only, common units of measurement should not be linked. See: wp:overlink.
{{convert|20.5|m3|cuyd|lk=out|abbr=on}} Template:Convert
Note 'lk=out' links only the output unit, cu yd.
{{convert|641|acre|ha sqmi|lk=on}} Template:Convert
Note 'lk=on' links all units. Per guidelines, common units should not be linked. See: wp:overlink.
{{convert|641|acre|ha sqmi|2|lk=on}} Template:Convert
Although 640 acres equals 1 square mile; 641 acres rounded to two decimal places equals 1.00 sq mi.

Range of 2 values

Note: not yet operational for all units and it may be necessary to enter as "convert/2" rather than simply "convert"
Input Displays as
{{convert|60|and|170|kg|lb}} Template:Convert
{{convert|60|to|170|kg|lb}} Template:Convert
{{convert|60|to(-)|170|kg|lb}} Template:Convert
{{convert|60|-|170|kg|lb}} Template:Convert
{{convert|41|to|50|F|C}} Template:Convert
{{convert|-10|to|-20|C|F}} Template:Convert
{{convert|41|-|50|F|K}} Template:Convert
{{convert|60|by|120|ft|m}} Template:Convert
{{convert|60|x|120|m|ft|abbr=on}} Template:Convert
{{convert|60|+/-|10|m|ft}} Template:Convert
{{convert|19|to|27|L|USgal}} Template:Convert
{{convert|5|to|7|L|USgal}} Template:Convert
{{convert|4|-|9|L|USgal|abbr=off}} Template:Convert

The following conversions are currently not available as a range of values:

  • Some imperial and US gallon-based units
  • Other fuel-consumption units, except "mpg" or "L100km" shown above.
  • Large scale units (e3, e6, e9)
  • Combination-based units (ft&in, st&lb, lb&oz) due to complexity of the conversion.

Range/set of 3 or 4 values

Note: not yet operational for all units
Input Displays as
{{convert |60|by|100|by|120|m|ft}} Template:Convert
{{convert/3 |60|x|100|x|120|m|ft|abbr=mos}} Template:Convert/3
{{convert/3 |60|-|70|-|80|kg|lb}} Template:Convert/3
{{convert/4 |60|-|70|-|80|-|90|kg|lb}} Template:Convert/4
{{convert/3 |60|to|80|or|85|m|ft}} Template:Convert/3
{{convert/3 |11|by|15|rarely|16|ft|m}} Template:Convert/3
{{convert/3 |41|to|50|to|60|F|C}} Template:Convert/3
{{convert/4 |2|to|12|, in summer|25|to|36|C|F}} Template:Convert/4
{{convert/3 |41|-|50|almost|51|F|K}} Template:Convert/3

For {{convert/3}} or {{convert/4}}, the separator words can be any text.

Parameters

Parameters
Use US spelling attach |sp=us   to show "meter" rather than "metre" (etc.)
Make units linked attach |lk=on   to link all units (default: lk=off)
attach |lk=in   to link only the input units
attach |lk=out  to link only the output units
(The manual of style suggests that you should not link common units of measurement).
Use the adjective form, or insert mid-text words attach |adj=on (e.g. "190-foot (58 m) bridge" instead of "190 feet...").
This produces the adjective form, as the unit name in the singular with a hyphen (according to the Manual of Style).

attach |adj=mid (e.g. "190-foot bridge (58 m)" as: |adj=mid|bridge

or "190-foot-long bridge (58 m)" as: |adj=mid|-long bridge

Note 1: Any rounding-parameter should follow the mid-text: "text|0".
Note 2: For adj=mid, must specify both input & output unit-codes.

For example, to convert feet, use "ft|m" or "ft|0":
  • {{convert|9|ft|m|adj=mid|-long}} → 9-foot-long (2.7 m)
To default the output unit-code, set parameter 3 to: 0.
Abbreviate units, or not attach |abbr=on    to show unit symbols
attach |abbr=off   to show all unit names in full words
attach |abbr=in    to abbreviate input units
attach |abbr=out   to abbreviate output units
attach |abbr=~      to show input unit symbol in result
attach |abbr=values to suppress unit names & show only values. So, {{convert|6|mi|abbr=values}} gives: Template:Convert.
Change "( )" to display other separators disp=or to put "or" between units.
The default value is:  disp=b for brackets/parentheses.
Change "( )" to customized separators disp=x| (begin | end) to show "xx (begin yy end)" See example 1
attach |disp=x|; to show "xx; yy" See example 2
attach |disp=x| (same as |) to show "xx (same as yy)". See example 3
Example 1: {{convert|9|km|mi|disp=x| [|]}}9 kilometres [5.6 mi] (note space before [|)
Example 2: {{convert|9|km|mi|disp=x|; }}9 kilometres; 5.6 mi
Example 3: {{convert|10|km|mi|disp=x| (about |)}}10 kilometres (about 6.2 mi) (note spaces used within the code).
Display output only disp=output only to show result number & unit
attach |disp=output number only to show just number
Note when using "disp=output only" then the unit name can still be shown as full words by abbr=off or linked by lk=on.
Example: {{convert|7500|acre|m2|disp=output only }} → Template:Convert
Display units inverted as reverse order disp=flip  to reverse the order & show output unit first.
So, {{convert|6|km|disp=flip}} shows "3.7 miles (6 km)".
To get symbol "mi" use abbr=in, to abbreviate the input unit (left-side unit).
Display unit name (only) disp=unit to show the unit name for a symbol
The unit name will be plural when the amount is not 1, or hyphenated when adj=on. So, {{convert|2|cuyd|disp=unit}} shows "cubic yards" plural.
Display amounts as table cells disp=table (or |disp=tablecen) Note: For use in tables, the template must start on a new line after a pipe. Only the number will be displayed unless you set |abbr=on, |lk=on, |lk=in or |lk=out. Example: here
Round to a specified number of significant figures attach |sigfig={some integer greater than zero}. In the case of temperatures Celsius or Fahrenheit this refers to the difference with the absolute-zero temperature. For example, at room temperature two significant digits means rounded to tens of degrees.
Round by 5 disp=5  to round the output amount to the nearest 5 units. Not supported for all options.
Let Convert decide the unit to convert to skip the precision parameter (the 3rd or 4th unnamed parameter) e.g. {{convert|100|km|ft}} gives Template:Convert and {{convert|100|km}} gives Template:Convert.
Display input value with a fraction {{convert|3/8|in|mm|3|abbr=on}} → Template:Convert or {{convert|11+1/4|in|cm|2|abbr=on}} → Template:Convert

For negative amounts, use two minus signs (hyphens): -11-1/4.

Generate a hidden sort key for use with a sortable table attach |sortable=on to generate a hidden sort key so that sortable tables will sort correctly. This uses {{ntsh}} to generate a sort key from the first numeric value. It ignores any additional values, ie, if you use 6|ft|2|in as the value, it will only use the 6 for the sort key. This will cause numeric values to sort in numeric order, ie: 5, 10, 15 instead of 10, 15, 5.

Parameters still under construction

Parameters still under construction. May not work in all situations
disp=5[note 1] The output will be rounded to the nearest 5 units. Might not work when linking unit names.
disp=tablecen[note 1] Similar to disp=table except that the values with be centered within the column. See the tables at La Nouvelle branch, BM-21 Grad for in use examples.
abbr=in Abbreviates only the input unit.
abbr=out Abbreviates only the output unit.
disp=br This separates input and output units with a forced line break. This can be useful in tables with limited horizontal space.
disp=sqbr Shows square brackets "[ ]" instead of parentheses "( )" in output. Example: 55 miles [89 km]. This option can be used in direct quotes, to show conversions in editorial brackets. See: attach |disp=x|[|], above, as another way of showing brackets "[ ]".
  1. 1.0 1.1 This is a limited, temporary option, until an alternative can be implemented.

Rounding

Convert supports four types of rounding:

Rounding to a given precision
Specify the desired precision with the fourth unnamed parameter (or third unnamed parameter if the "convert to" parameter is omitted; or fifth unnamed parameter if a range is specified; or fourth unnamed parameter again if a range is specified and the "convert to" parameter is omitted; needs to be replaced with a "precision" named parameter). The conversion is rounded off to the nearest power of 110 this number. For instance, if the result is 8621 and the round number is '-2', the result will be 8600. If the result is '234.0283043' and the round number is '0', the result will be 234.
Rounding to a given number of significant figures
Specify the desired number of significant figures using |sigfig={some integer greater than zero} as noted above.
Default rounding
If neither the desired precision nor the desired number of significant figures is specified, the conversion will be rounded either to precision comparable to that of the input value (the number of digits after the decimal point—or the negative of the number of non-significant zeroes before the point—is increased by one if the conversion is a multiplication by a number between 0.02 and 0.2, remains the same if the factor is between 0.2 and 2, is decreased by 1 if it is between 2 and 20, and so on) or to two significant figures, whichever is more precise. An exception to this is temperature, wherein the conversion will be rounded either to precision comparable to that of the input value or to that which would give three significant figures when expressed in kelvins, whichever is more precise.
Examples of default rounding
Input Displays as Note
{{convert|550|ft|m|0}} Template:Convert Approximate value is 167.64 m
{{convert|550|ft|m}} Template:Convert Rounds to 170, when approximate value is 167.64 m
{{convert|500|ft|m|0}} Template:Convert Approximate value is 152.4 m
{{convert|500|ft|m}} Template:Convert Rounds to 150, when approximate value is 152.4 m

Units supported

Template:Selfref

The table below lists units supported by this template. It is divided up according to the quantity being measured. Not all supported units are listed here; there are links to more complete lists for each quantity.

The codes listed in the code column (column 3) are accepted as input by the template. These can be used as the second or third unnamed parameter. For some units there exist alternative codes. These are listed in brackets and have been incorporated to make the code more flexible for editors, e.g. °F or F may be entered.

The codes listed in the combinations column (column 7) can be used to produce multiple conversions. They can only be used as the third unnamed parameter, e.g. {{convert|55|nmi|km mi}} produces "Template:Convert".

Abridged list of units supported by {{Convert}}
Explanation
system unit unit-
code
symbol or
abbrev.
notes sample default
conversion
combination
output units
the system(s) to which the unit belongs units listed by name unit-code to use in template symbols shown in output other notes about the units sample of the default conversion for the unit output codes for multiple conversions


LENGTH
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert Mm (none) US spelling: megameter
Template:Convert
Template:Convert km (none) US spelling: kilometer
Template:Convert
  • km mi
Template:Convert m (none) US spelling: meter
Template:Convert
  • m ft
  • m ftin
Template:Convert cm (none) US spelling: centimeter
Template:Convert
  • cm in
Template:Convert mm (none) US spelling: millimeter
Template:Convert
  • mm in
Template:Convert μm (um) (none) US spelling: micrometer
Template:Convert
Template:Convert nm (none) US spelling: nanometer
Template:Convert
non-SI metric Template:Convert Å
(angstrom)
(none) Template:Convert
Imperial
&
US customary
Template:Convert mi (none) Template:Convert
  • mi km
Template:Convert furlong (none) Template:Convert
Template:Convert chain (none) Template:Convert
Template:Convert rd (none) For other names of this unit see the full list. Template:Convert
Template:Convert fathom (none) assumes 1 fathom ≡ 6 ft Template:Convert
Template:Convert yd (none) assumes the international definition Template:Convert
Template:Convert ft (foot) (none) code "foot" will show "foot" if plural.

code "ft" will show "foot" or "feet" depending on value.

Template:Convert
  • ftin (feet and inches)
  • ft m (foot m)
Template:Convert in (none) Template:Convert
  • in cm
  • in mm
Other Template:Convert nmi (none) the international standard nautical mile
For other nautical miles see the full list.
Template:Convert
Template:Convert pc (none) Template:Convert
Template:Convert ly (none) Template:Convert
Template:Convert AU (none) Template:Convert


AREA
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert km2 (none) US spelling: square kilometer
Template:Convert
  • km2 sqmi
Template:Convert m2 (none) US spelling: square meter
Template:Convert
  • m2 sqft
Template:Convert cm2 (none) US spelling: square centimeter
Template:Convert
  • cm2 sqin
Template:Convert mm2 (none) US spelling: square millimeter
Template:Convert
  • mm2 sqin
non-SI metric Template:Convert ha (none) Template:Convert
Imperial
&
US customary
Template:Convert sqmi (none) Template:Convert
  • sqmi km2
Template:Convert acre (none) Template:Convert
Template:Convert sqyd (none) Template:Convert
Template:Convert sqft
(sqfoot)
(none) code "sqfoot" will show "square foot" if plural.

code "sqfoot" will show "foot" or "feet" depending on value.

Template:Convert
  • sqft m2 (sqfoot m2)
Template:Convert sqin (none) Template:Convert
  • sqin cm2
Other Template:Convert sqnmi (none) Template:Convert
Template:Convert dunam (none) For alternative spellings and definitions see the full list Template:Convert
Template:Convert tsubo (none) Template:Convert


VOLUME
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert m3 (none) US spelling: cubic meter
one kilolitre
Template:Convert
Template:Convert cm3 (none) US spelling: cubic centimeter
one millilitre
Template:Convert
cc Template:Convert
Template:Convert mm3 (none) US spelling: cubic millimeter
Template:Convert
non-SI metric Template:Convert kl (none) US spelling: kiloliter
one cubic metre
Template:Convert
kL Template:Convert
Template:Convert l (none) US spelling: liter
one cubic decimetre
Allows triple output units. See: full list.
Template:Convert
  • l impgal
  • l USgal
  • l U.S.gal
  • l USdrygal
  • l U.S.drygal
L Template:Convert
  • L impgal
  • L impqt
  • L USgal
  • L U.S.gal
  • L USdrygal
  • L U.S.drygal
Template:Convert cl (none) US spelling: centiliter
Template:Convert
cL Template:Convert
Template:Convert ml (none) US spelling: milliliter
one cubic centimetre
Template:Convert
  • ml impoz
  • ml USoz
  • ml U.S.oz
mL Template:Convert
  • mL impoz
  • mL USoz
  • mL U.S.oz
Imperial
&
US customary
Template:Convert cuyd (none) Template:Convert
Template:Convert cuft (cufoot) (none) code "cufoot" will show "cubic foot" if plural.

code "cufoot" will show "foot" or "feet" depending on value.

Template:Convert
Template:Convert cuin (none) Template:Convert
Imperial Template:Convert impbbl (none) 36 imp gal Template:Convert
Template:Convert impbsh (none) 8 imp gal Template:Convert
impbu Template:Convert
Template:Convert impgal (none) 4.54609 litres by definition, also
4 imp qt or 8 imp pt or 160 imp fl oz
Allows triple output units. See: full list.
Template:Convert
  • impgal l
  • impgal L
  • impgal USgal
  • impgal U.S.gal
  • impgal USdrygal
  • impgal U.S.drygal
Template:Convert impqt (none) 1/4 imp gal or 40 imp fl oz Template:Convert
Template:Convert imppt (none) 1/8 imp gal or 20 imp fl oz Template:Convert
Template:Convert impoz (impfloz) (none) 1/160 imp gal Template:Convert
  • impoz USoz
  • impoz U.S.oz
  • impoz ml
  • impoz mL
US customary
liquid measure
Template:Convert USbbl (none) 31½ US gal
used for liquids except for oil and beer (see the full list)
Template:Convert
U.S.bbl Template:Convert
Template:Convert oilbbl (none) 42 US gal Template:Convert
Template:Convert USbeerbbl
(usbeerbbl)
(none) Template:Convert
U.S.beerbbl
(usbeerbbl)
Template:Convert
Template:Convert USgal (none) 231 cubic inches by definition, also
4 US qt or 8 US pt or 128 US fl oz
Allows triple output units. See: full list.
Template:Convert
  • USgal l
  • USgal L
  • USgal impgal
U.S.gal Template:Convert
  • USgal l
  • USgal L
  • USgal impgal
Template:Convert USqt (none) 1/4 US gal or 32 US fl oz Template:Convert
U.S.qt Template:Convert
Template:Convert USpt (none) 1/8 US gal or 16 US fl oz Template:Convert
U.S.pt Template:Convert
Template:Convert USoz
(USfloz)
(none) 1/128 US gal Template:Convert
  • USoz ml
  • USoz mL
  • USoz impoz
U.S.oz
(U.S.floz)
Template:Convert
  • U.S.oz ml
  • U.S.oz mL
  • U.S.oz impoz
US customary
dry measure
Template:Convert USdrybbl (none) 105/32 US bsh Template:Convert
U.S.drybbl Template:Convert
Template:Convert USbsh (none) 2150.42 cubic inches by definition Template:Convert
U.S.bsh Template:Convert
Template:Convert USbu (none) 2150.42 cubic inches by definition Template:Convert
U.S.bu Template:Convert
Template:Convert USdrygal (none) 1/8 US bsh
Allows triple output units. See: full list.
Template:Convert
  • USdrygal l
  • USdrygal L
  • USdrygal impgal
U.S.drygal Template:Convert
  • U.S.drygal l
  • U.S.drygal L
  • U.S.drygal impgal
Template:Convert USdryqt (none) 1/32 US bsh Template:Convert
U.S.dryqt Template:Convert
Template:Convert USdrypt (none) 1/32 US bsh Template:Convert
U.S.drypt Template:Convert


SPEED
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert m/s (none) US spelling: meter per second
Template:Convert
  • m/s ft/s (m/s foot/s)
non-SI metric Template:Convert km/h (none) US spelling: kilometer per hour
Template:Convert
  • km/h mph
Imperial
&
US customary
Template:Convert mph (none) Template:Convert
  • mph km/h
  • mph kn
Template:Convert ft/s (foot/s) (none) code "foot/s" will show "foot per second" if plural.

code "foot/s" will show "foot" or "feet" depending on value.

Template:Convert
  • ft/s m/s
Maritime units Template:Convert kn (knot) (none) Template:Convert
  • kn mph


FORCE
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert GN (none) Allows triple output units. See: full list. Template:Convert
  • GN LT-f
  • GN LTf
  • GN ST-f
  • GN STf
Template:Convert MN (none) Allows triple output units. See: full list. Template:Convert
  • MN LT-f
  • MN LTf
  • MN ST-f
  • MN STf
Template:Convert kN (none) Allows triple output units. See: full list. Template:Convert
  • kN LT-f
  • kN LTf
  • kN ST-f
  • kN STf
Template:Convert N (none) Template:Convert
  • N lb-f
  • N lbf
  • N oz-f
  • N ozf
Template:Convert mN (none) Template:Convert
  • mN oz-f
  • mN ozf
  • mN gr-f
  • mN grf
Template:Convert μN (uN) (none) Template:Convert
  • μN gr-f
  • μN grf
Template:Convert nN (none) Template:Convert
  • nN gr-f
  • nN grf
cgs Template:Convert Mdyn (none) Template:Convert
Template:Convert kdyn (none) Template:Convert
Template:Convert dyn
(dyne)
(none) Template:Convert
Template:Convert mdyn (none) Template:Convert
Metric gravitational units Template:Convert t-f (none) Template:Convert
tf Template:Convert
Template:Convert kg-f (none) Template:Convert
kgf Template:Convert
Template:Convert g-f (none) Template:Convert
gf Template:Convert
Template:Convert mg-f (none) Template:Convert
mgf Template:Convert
Avoirdupois-based units Template:Convert pdl (none) Template:Convert
Template:Convert LT-f (none) Template:Convert
  • LT-f ST-f
LTf Template:Convert
  • LTf STf
Template:Convert ST-f (none) Template:Convert
  • ST-f LT-f
STf Template:Convert
  • STf LTf
Template:Convert lb-f (none) Template:Convert
lbf Template:Convert
Template:Convert gr-f (none) Template:Convert
grf Template:Convert


ENERGY
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert GJ (none) Template:Convert
Template:Convert MJ (none) Template:Convert
Template:Convert kJ (none) Template:Convert
Template:Convert hJ (none) Template:Convert
Template:Convert daJ (none) Template:Convert
Template:Convert J (none) Template:Convert
Template:Convert dJ (none) Template:Convert
Template:Convert cJ (none) Template:Convert
Template:Convert mJ (none) Template:Convert
Template:Convert μJ (uJ) (none) Template:Convert
Template:Convert nJ (none) Template:Convert
cgs Template:Convert Merg (none) Template:Convert
Template:Convert kerg (none) Template:Convert
Template:Convert erg (none) Template:Convert
Watt-hour multiples Template:Convert TWh (none) Template:Convert
TW.h Template:Convert
Template:Convert GWh (none) Template:Convert
GW.h Template:Convert
Template:Convert MWh (none) Template:Convert
MW.h Template:Convert
Template:Convert kWh (none) Template:Convert
kW.h Template:Convert
Template:Convert Wh (none) Template:Convert
W.h Template:Convert
Electron-
volt
multiples
Template:Convert GeV (none) Template:Convert
Template:Convert MeV (none) Template:Convert
Template:Convert keV (none) Template:Convert
Template:Convert eV (none) Template:Convert
Template:Convert meV (none) Template:Convert
Calorie multiples Template:Convert Cal (none) The thermo-chemical calorie is the default definition. For others, see the full list. Template:Convert
Template:Convert Mcal (none) Template:Convert
Template:Convert kcal (none) Template:Convert
Template:Convert cal (none) Template:Convert
Template:Convert mcal (none) Template:Convert
pound/
ounce
-foot/
inch-hour-minute-second
Template:Convert ftpdl (none) Template:Convert
Template:Convert ftlbf (none) Template:Convert
ftlb-f Template:Convert
Template:Convert inlbf (none) Template:Convert
inlb-f Template:Convert
Template:Convert inozf (none) Template:Convert
inoz-f Template:Convert
Template:Convert hph (none) Template:Convert
British thermal unit Template:Convert Btu (none) The International Steam Table British thermal unit is used. For others, see the full list. Template:Convert
BTU Template:Convert
TNT-based units Template:Convert GtTNT (none) Template:Convert
Template:Convert GtonTNT (none)
Template:Convert MtTNT (none) Template:Convert
Template:Convert MtonTNT (none)
Template:Convert ktTNT (none) Template:Convert
Template:Convert ktonTNT (none)
Template:Convert tTNT (none) Template:Convert
Template:Convert tonTNT (none)
Other
Template:Convert Eh (none) Template:Convert
Template:Convert Ry (none) Template:Convert
Template:Convert toe (none) Template:Convert
Template:Convert BOE (none) Template:Convert
cubic foot of natural gas cuftnaturalgas (cufootnaturalgas) Unit-code cufootnaturalgas will show "cubic foot of natural gas" if plural. Template:Convert
Template:Convert latm (none) Template:Convert
Latm Template:Convert
Template:Convert impgalatm (none) Template:Convert
Template:Convert USgalatm
(usgalatm)
(none) Template:Convert
U.S.galatm
(usgalatm)
Template:Convert


TEMPERATURE
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert K (none) Allows triple output units. See: full list. Template:Convert
  • K °C (K C)
  • K °R (K R)
  • K °F (K F)
Template:Convert °C (C) (none) Template:Convert
  • °C K (C K)
  • °C °R (C R)
  • °C °F (C F)
Imperial
&
US customary
Template:Convert °R (R) (none) Template:Convert
  • °R K (R K)
  • °R °C (R C)
  • °R °F (R F)
Template:Convert °F (F) (none) Template:Convert
  • °F K (F K)
  • °F °C (F C)
  • °F °R (F R)
Celsius change C-change Used for temperature intervals instead of absolute temperatures
Example:  {{convert|5|C-change|0}} warmer
Result: Template:Convert warmer
Fahrenheit change F-change Used for temperature intervals instead of absolute temperatures
Example:  {{convert|10|F-change|0}} colder
Result: Template:Convert colder


MASS
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI Template:Convert kg (none) Allows triple output units. See: full list. Template:Convert
  • kg lb
  • kg st
Template:Convert g (none) Template:Convert
  • g oz
Template:Convert mg (none) Template:Convert
  • mg gr
Template:Convert μg (ug) (none) Template:Convert
non-SI metric Template:Convert t (none) Allows triple output units. See: full list. Template:Convert
  • t LT
  • t ST
Template:Convert MT (none)
  • MT LT
  • MT ST
Avoirdupois Template:Convert LT (none) 2,240 lb
used mostly in the British Commonwealth.
Allows triple output units. See: full list.
Template:Convert
  • LT t
  • LT MT
  • LT ST
long ton Template:Convert
Template:Convert ST (none) 2,000 lb
used mostly in the US.
Allows triple output units. See: full list.
Template:Convert
  • ST t
  • ST MT
  • ST LT
short ton Template:Convert
Template:Convert st (none) 14 lb
used mostly in the British Commonwealth except Canada.
Allows triple output units. See: full list.
Template:Convert
  • st kg
  • st lb
Template:Convert lb (none) Allows triple output units. See: full list. Template:Convert
  • lb kg
  • lb st
Template:Convert oz (none) Template:Convert
  • oz g
Template:Convert drachm (none) Template:Convert
Template:Convert dram (none)
Template:Convert gr (none) equivalent to the troy grain Template:Convert
Troy Template:Convert ozt (none) Template:Convert
other Template:Convert carat (none) Template:Convert


TORQUE
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
Industrial
SI Template:Convert Nm (none) Triple combinations are also possible. See the full list. Template:Convert
  • Nm kg.m
  • Nm lb.ft
Non-SI metric Template:Convert kg.m (none) Template:Convert
  • kg.m Nm
  • kg.m lb.ft
Imperial
&
US customary
Template:Convert lb.ft (none) Template:Convert
  • lb.ft Nm
  • lb.ft kg-m
Scientific
SI Template:Convert N.m (none) Triple combinations are also possible. See the full list. Template:Convert
  • N.m kgf.m
  • N.m lbf.ft
Non-SI metric Template:Convert kgf.m (none) Template:Convert
  • kgf.m N.m
  • kgf.m lbf.ft
Imperial
&
US customary
Template:Convert lbf.ft (none) Template:Convert
  • lbf.ft N.m
  • lbf.ft kgf.m
DENSITY
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
Metric Template:Convert kg/m3 (none) Template:Convert
  • kg/m3 lb/ft3 (kg/m3 lb/cuft)
  • kg/m3 lb/yd3 (kg/m3 lb/cuyd)
Template:Convert g/m3 (none) Template:Convert
  • g/m3 kg/m3
  • g/m3 lb/ft3 (g/cm3 lb/cuft)
  • g/m3 lb/yd3 (g/cm3 lb/cuyd)
Imperial
&
US customary
Template:Convert lb/ft3 (none) Template:Convert
  • lb/ft3 kg/m3 (lb/cu ft g/m3)
  • lb/ft3 g/m3 (lb/cu ft g/m3)
Template:Convert lb/yd3 (none) Template:Convert
  • lb/yd3 kg/m3 (lb/cuyd kg/m3)
  • lb/yd3 g/m3 (lb/cuyd g/m3)


PRESSURE
unit unit-
code
abbrev-
iation
sample default
conversion
Template:Convert GPa (none) Template:Convert
Template:Convert MPa (none) Template:Convert
Template:Convert kPa (none) Template:Convert
Template:Convert hPa (none) Template:Convert
Template:Convert Pa (none) Template:Convert
Template:Convert mPa (none) Template:Convert
Template:Convert mbar (none) Template:Convert
mb Template:Convert
Template:Convert dbar (none) Template:Convert
Template:Convert bar (none) Template:Convert
Template:Convert kBa (none) Template:Convert
Template:Convert Ba (none) Template:Convert
Template:Convert atm (none) Template:Convert
Template:Convert Torr (none) Template:Convert
Template:Convert mmHg (none) Template:Convert
Template:Convert inHg (none) Template:Convert
Template:Convert psi (none) Template:Convert
FUEL EFFICIENCY
unit unit-
code
notes combinations
kilometres per litre km/l (km/L) Use km/L to get "km/L"
  • km/l mpgimp
  • km/l mpgus
litres per 100 kilometres l/100 km (L/100 km) Use L/100 km to get "L/100 km"
  • l/100 km mpgimp
  • l/100 km mpgus
litres per kilometre l/km (L/km) Use L/km to get "L/km"
  • l/km impgal/mi
  • l/km usgal/mi
miles per imperial gallon mpgimp
  • mpgimp mpgus
miles per US gallon mpgus (mpgUS, mpgU.S.) Use mpgUS to get "US"

Use mpgU.S. to get "U.S."
mpgus will give "U.S." if spelling is
set to US & "US" otherwise

  • mpgus mpgimp
imperial gallons per mile impgal/mi
  • impgal/mi
US gallons per mile usgal/mi (USgal/mi, U.S.gal/mi) As above with the us vs US vs U.S.
  • usgal/mi
The mpgUS, mpgU.S., USgal/mi vs U.S.gal/mi, km/L, L/100 km and L/km variants work within combinations also (making 36 combinations in total).
POWER
Watts, kilowatts, milliwatts, etc. are supported. As is horsepower (English & metric). Use standard abbreviations as input code (lowercase hp for horsepower, for example)
POPULATION DENSITY
unit unit-
code
notes combinations
inhabitants per square kilometre PD/sqkm PD stands for population density, i.e. humans (inhabitants)
  • PD/sqkm PD/sqmi
per square kilometre /sqkm Used when the word 'inhabitants' would be inappropriate.
  • /sqkm /sqmi
inhabitants per hectare PD/ha
  • PD/ha PD/acre
per hectare /ha
  • /ha /acre
inhabitants per square mile PD/sqmi PD stands for population density, i.e. humans (inhabitants)
  • PD/sqmi PD/sqkm
per square mile /sqmi Used when the word 'inhabitants' would be inappropriate.
  • /sqmi /sqkm
inhabitants per acre PD/acre
  • PD/acre PD/ha
per acre /acre
  • /acre /ha
COST PER UNIT MASS
unit unit-
code
notes combinations
dollars per pound $/lb "$" can mean US$, HK$, etc.
  • (none)
dollars per kilogram $/kg
  • (none)
dollars per troy ounce $/ozt 12 troy ounces in 1 troy pound
  • (none)

Examples

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Convert

<templatedata>{ "description": "Converts measurements to other units.", "params": { "1": {

 "label": "value",
 "description": "the value to convert",
 "type": "number"

}, "2": {

 "label": "from unit",
 "description": "",
 "type": "string/line"

}, "3": {

 "label": "to units",
 "description": "",
 "type": "string/line"

}, "4": {

 "label": "precision or suffix",
 "description": "significant digits after decimal dot or, if negative, exponent of ten",
 "type": "number"

}, "lk": {

 "label": "link units",
 "description": "“on” all, “in” input, “out” output or “off” no units",
 "default": "off",
 "type": "string/line"

}, "abbr": {

 "label": "abbreviation",
 "description": "show “on” unit symbols, “off” all unit names in full words, “in” abbreviated input units, “out” abbreviated output units or “values” no unit names",
 "type": "string/line"

}, "sp": {

 "label": "spelling",
 "description": "“us” US",
 "type": "string/line"

}, "adj": {

 "label": "adjective",
 "description": "adjective form (singular unit name appended by hyphen) “on” or “mid” to put conversion at end",
 "type": "string/line"

}, "disp": {

 "label": "conversion",
 "description": "show conversion … “or” after ‘or’, “b” in parentheses, “x” with custom prefix and suffix, “table”/“tablecen”, “output only” alone, “output number only” alone and without unit, “flip” first, “unit” not at all but input unit; if the value is a number it is used as precision",
 "default": "b",
 "type": "string/line"

}, "sigfig": {

 "label": "significant figures",
 "description": "number that sets the number of significant figures",
 "type": "number"

}, "sortable": {

 "label": "sort key",
 "description": "“on” generate a hidden sort key",
 "type": "string/line"

} }}</templatedata>

See also