Template {{convert}}calculates from one measurement unit to another one, and then presents the results, formatted. The complete list of unit symbols recognized by the template is here.
For example:
{{convert|2|km|mi}} → kilometre 2 (mi 1.2) (km entered, converted into miles)
{{convert|7|mi|km}} → mile 7 (km 11) (mi entered, converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}} → km 2 (mi 1.24)
{{convert|7|mi|km|2|abbr=on}} → mi 7 (km 11.27)
Value ranges can be entered using |to|... or |-|...:
{{convert|2|to|5|km|mi}} → kilometre 2 hadi 5 (mi 1.2 hadi 3.1)
{{convert|2|-|5|km|mi}} → kilometre 2–5 (mi 1.2–3.1)
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}} → km 2–5 (mi 1.24–3.11)
{{convert|2|and|5|km|mi|sigfig=3|abbr=off}} → kilometre 2 na 5 (mile 1.24 na 3.11)
See Help:Convert for more detailed, technical information
By definition, 100 ft equals m 30.48. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
By {{Convert}} default, the conversion result 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 digits, whichever is more precise. An exception to this is rounding temperatures (see below).
Examples of rounding
Input
Displays as
Note
{{convert|123|ft|m|-1}}
feet 123 (m 40)
{{convert|123|ft|m}}
feet 123 (m 37)
same output as with 0 (below)
{{convert|123|ft|m|0}}
feet 123 (m 37)
{{convert|123|ft|m|1}}
feet 123 (m 37.5)
{{convert|123|ft|m|2}}
feet 123 (m 37.49)
The more-exact value is 37.4904 m or so, which gets converted to 37 m if this parameter is not specified at all.
{{convert|500|ft|m|-1}}
feet 500 (m 150)
{{convert|500|ft|m}}
feet 500 (m 150)
same output as with −1 (above), because the conversion factor is between 0.2 and 2 (hence, it should produce same double-zero precision (−2) as in the input value), but the conversion must produce two significant digits at a minimum (hence, a higher single-zero precision (−1) is used)
{{convert|500|ft|m|0}}
feet 500 (m 152)
{{convert|500|ft|m|1}}
feet 500 (m 152.4)
{{convert|500|ft|m|2}}
feet 500 (m 152.40)
exact value is 152.4 m
{{convert|500|ft|cm|-3}}
feet 500 (cm 15 000)
{{convert|500|ft|cm}}
feet 500 (cm 15 000)
same output as with −3 (above), because the conversion factor is between 20 and 200 (hence, it should decrease input value's double-zero precision (−2) by 2), but the conversion must produce two significant digits at a minimum (hence, a higher triple-zero precision (−3) is used)
{{convert|500|ft|cm|0}}
feet 500 (cm 15 240)
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 multiple of 1⁄10 to the power of 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.
Round to a given number of significant figures: |sigfig=
In temperatures, the conversion will be rounded either to the 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.
{{convert|10,000|C|F K}} → °C 10 000 (°F 18 000; K 10 300)
{{convert|10,000.1|C|F K}} → °C 10 000.1 (°F 18 032.2; K 10 273.2)
{{convert|-272|C|F K}} → °C −272 (°F −457.60; K 1.15)
{{convert|-272|C}} → °C −272 (°F −457.60)
{{convert|100|C|F K}} → °C 100 (°F 212; K 373)
{{convert|0|C|F K}} → °C 0 (°F 32; K 273)
The precision of the input number in example (1) is one digit, but the precision of its Kelvins expression is three, so the precision of the Fahrenheit conversion is made three (made 180...) . (1) and (2) seem to belie the fact that a degrees Celsius change 0.1 is a degrees Fahrenheit change 0.18, and make the 32 degrees difference shown in (1) begin to seem off somehow.
Result (1) seems off until you set the significant figures yourself with |sigfig=:
{{convert|10000|C|sigfig=5}} → °C 10 000 (°F 18 032)
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
{{convert|10000|C|0}} → °C 10 000 (°F 18 032)
The precision of the input number in example (2) is six, so the precision of the Fahrenheit output is, whereas before, Kelvins had determined it to be three. Examples (3) and (4) show how this can be hidden and generate questions, but it occurs there because the Kelvins conversion generated two fractional parts. (Before it was the input number that generated the fractional part.) In example (3) the three input digits converted into five significant output digits because of the two digits after the decimal point, generated by the Kelvins conversion. This happened again in (5), but in (6) decimal fractions were neither given as input nor induced by the Kelvins conversion.
There is limited support for rounding the displayed input number. The rounding takes place after conversion, so the output is based on the full-precision input. This is useful when the input is produced by {{#expr:}} or otherwise available to a higher precision than is usefully displayed, and it's desirable to avoid double-rounding.
To round the input to a specified number of digits after the decimal point, use one of the parameters:
|adj=ri0
|adj=ri1
|adj=ri2
|adj=ri3
Note that there is no |adj=ri-1N or similar for rounding above the decimal place. Neither is there support for significant figures, multiples of 5, or any other output-rounding feature.
The default precision is computed based on the input, so an explicit output precision must usually be supplied:
{{convert|4.14159|mi|km|adj=ri0}} → mile 4 (km 6.66524) N (precisions are mismatched)
{{convert|4.14159|mi|km|0|adj=ri0}} → mile 4 (km 7) Y
In this case, if the input were rounded before conversion, a different result would be obtained:
In scientific notation, a number is written like 1.23×10−14. The plain number has exactly one digit before the decimal point.
With {{convert}}, the input can be in e-notation such as 12.3e4. This value is displayed as a power of ten, and the output is displayed in scientific notation, except that an output value satisfying 0.01 <= v < 1000 is shown as a normal number. In addition, if the output value is 1000 and sigfig=4 is used, the value is displayed as a normal number.
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}} → inch 2–1⁄2 (mm 50.8–12.7). This is interpreted as a range from 2 inches to 1⁄2 inch.
{{convert|-2+1⁄2|in|mm|1}} → [convert: invalid number]N This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
In input, a comma for thousands separator is accepted but not required; a gap (space) is not accepted. In output, by default, the thousand separator is the comma:
{{convert|1234567|m|ft}} → metre 1 234 567 (ft 4 050 417)
{{convert|1,234,567|m|ft}} → metre 1 234 567 (ft 4 050 417)
Set |comma=off to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}} → metre 1234567 (ft 4050417)
Use |comma=gaps to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}} → metre 1234567 (ft 4050417)
Default behaviour, for comparison:
{{convert|1234567|m|ft}} → metre 1 234 567 (ft 4 050 417)
Setting |comma=5 will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}} → metre 1234 (ft 4049)
{{convert|1234567|m|ft|comma=5}} → metre 1 234 567 (ft 4 050 417)
Using {convert} in a table cell, with |disp=table splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the |abbr= parameter. Multiple-unit outputs, like ftin, always output their units to the table.
Use |sortable=on to include a hidden numerical sortkey in the output, suitable for use in a table with sortable columns. Technically, this places a hidden string before the actual displayed values:
Use both |disp=table and |sortable=on together to produce table columns (pipe symbols) for each value in sortable columns:
m
m
ft
A
Kosa la hati: Hakuna moduli kama "val".
153⁄4
52
B
Kosa la hati: Hakuna moduli kama "val".
15.5
51
C
Kosa la hati: Hakuna moduli kama "val".
16.0
52.5
D
Kosa la hati: Hakuna moduli kama "val".
16
52
The generated sortkey is calculated in a consistent way based on both the value and its unit as passed to the convert template. In most cases convert uses the passed value converted to SI base units. It is therefore not necessarily the displayed value or other alternate units and is calculated regardless of output format options. Using different units or different order of units in individual rows should therefore not lead to incorrect sorting, although variations in rounding can give surprising results, since an unrounded number is used for the sortkey.
The table below lists units supported by {{convert}}. More complete lists are linked for each dimension. For a complete list of all dimensions, see full list of units.
Table of contents
{{Convert}} uses unit-codes, which are similar to, but not necessarily exactly the same as, the usual written abbreviation for a given unit. These unit-codes are displayed in column 3 of the following tables. These are accepted as input by {{convert}} as the second and third unnamed parameters:
{{convert|100|kg|lb}} → kilogram 100 (lb 220)
{{convert|100|lb|kg}} → pound 100 (kg 45)
The unit-codes should be treated as case-sensitive:
The output of {{convert}} can display multiple converted units, if further unit-codes are specified after the second unnamed parameter (without the pipe separator). Typical combination output units are listed below in column 7.
{{convert|55|nmi|km mi}} → nautical mile 55 (km 102; mi 63)
{{convert|1|oz|ozt g gr}} → ounce 1 (ozt 0.91; g 28; gr 440)
Some units have alternative unit-codes. These are shown in brackets in column 3, e.g. °F (F). Either may be entered for Fahrenheit (but not a lower-case f).
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
{{convert|10|C}} → °C 10 (°F 50) (standard temperature conversion)
{{convert|10–15|C}} → °C 10–15 (°F 50–59) (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (|C, |F and |K), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": |C-change, |F-change and |K-change.
Compare the following two examples with the two above:
{{convert|10|C-change}} → °C 10 (°F 18) increase in temperature
{{convert|10–15|C-change}} → °C 10–15 (°F 18–27) warmer than normal
To produce multiple units in the output:
{{convert|10|C-change|F-change K-change}} → °C 10 (°F 18; K 10) difference
Base document § Input multiples lists options for multiple unit input (like ft,in). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
For usage in template code, like infoboxes, {{Convert}} has these options:
Pre-formatting fraction input
Module:Convert/helper can read regular input and pre-format it into {{Convert}}-accepted input.
Your template can accept |input=16 7/8 and use {{#invoke:Convert/helper|number|16 7/8}} → 16+7/8
Using a Wikidata property
Adding the Wikidata property code, like code |input=P2073, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use |qid=.
Example for (P2073):
Note: this example uses |qid=Q1056131 (testing for (Q1056131))
Sometimes a property may have more than one value against it in Wikidata. You can use the |qual= parameter to specify which of the values you want to use.
Example for (P2386):
Note: this example uses |qid=Q1513315 (testing for (Q1513315))
(Q613628): {{convert|input=P2386|qual=Q613628|ft|abbr=on}} → m 10.0 (ft 32.8)
(Q1395645): {{convert|input=P2386|qual=Q1395645|ft|abbr=on}} → m 1 (ft 3.3)
Use symbol for all units when using scientific notation
Unit display
|abbr=values
values
Omit both the input and output units: show only the numbers
Unit display
|abbr=~
~
Shows both unit name and symbol
Unit display
|adj=mid|…
mid
User-specified text after the input unit; sets adj=on (adjective). Expects 1 unnamed parameter.
Word adding, adjective
|adj=on
on
Unit name is adjective (singular and hyphenated)
Grammar, adjective
|adj=pre|…
pre
User-specified text before input unit. Expects 1 unnamed parameter.
Word adding
|adj=ri0
ri0
Round input with precision 0
Input precision
|adj=ri1
ri1
Round input with precision 1
Input precision
|adj=ri2
ri2
Round input with precision 2
Input precision
|adj=ri3
ri3
Round input with precision 3
Input precision
|comma=5
5
Only use comma for thousands separator if 5 or more digits
Number format
|comma=gaps
gaps
Use gaps (space), not comma, for thousands separator
Number format
|comma=off
off
No thousands separator
Number format
|disp=b
b
Join input and output using " (...)" (default)
Join values
|disp=sqbr
sqbr
Join input and output using " [...]"
Join values
|disp=br
br
Join input and output using "<br/>"
Join values
|disp=comma
comma
Join input and output using ", "
Join values
|disp=or
or
Join input and output using " or "
Join values
|disp=number
number
Display output number only
Parts only
|disp=output number only
output number only
|disp=out
out
Display only output number and name/symbol
Parts only
|disp=output only
output only
|disp=preunit|…[|…]
preunit
Text to be inserted after value and before units, for both input and output, with optionally different text for output. Expects 1 or 2 unnamed parameters.
Word adding
|disp=table
table
Output is suitable for a table cell with align="right"
Table columns
|disp=tablecen
tablecen
Output is suitable for a table cell with align="center"
Table columns
|disp=unit
unit
Display input name/symbol only (not input number, not output)
Parts only
|disp=unit2
unit2
Display output name/symbol only (not input; not output number)
Parts only
|disp=x|…
x
Join input and output using user-specified text
Word adding
|frac=N
N
Show imperial number in fractions, denominator=N
Number format, fraction
|input=P2048
P2048(e.g.)
Reads and converts Wikidata property
Inside template
|lk=in
in
Link left-hand side unit name or symbol
Unit link
|lk=on
on
Link all unit names or symbols (but not twice for the same unit)
Unit link
|lk=out
out
Link right-hand side unit name or symbol
Unit link
|order=flip
flip
Inverts order of input, output measurements (conversion first)
Order
|order=out
out
Displays output units in the order entered, skipping input unit
Order
|qid=Q1056131
Q1056131(e.g.)
Reads Wikidata property from Wikidata item
Inside template; testing
|qual=Q613628
Q613628(e.g.)
Qualify Wikidata property
|round=5
5
Rounds calculation to the nearest multiple of 5
Output precision
|round=25
25
Rounds calculation to the nearest multiple of 25
Output precision
|round=each
each
In a range, each number is rounded by the default rounding
Output precision
|sigfig=N
N
Round output number to N significant figures (N is a positive integer)
Output precision
|sortable=on
on
Adds invisible sort key
Table sort
|sp=us
us
Use U.S. spelling ("meter" instead of default "metre")
Spelling U.S. names
|spell=in
in
Spell input number in words
Spelling numbers
|spell=In
In
Spell input number in words with first letter uppercase
Spelling numbers
|spell=on
on
Spell input and output numbers in words
Spelling numbers
|spell=On
On
Spell input and output numbers in words with first letter uppercase
Spelling numbers
|$=€
€
Replace $-sign with a currency sign, for example in €/hectare
Cost per unit No currency conversion happens
|debug=yes
yes
Debugging only. In a sortable table: show the normally hidden sort key
Deprecated options should not be used. They may produce incorrect or undesired results and there is no guarantee that they will be supported in the future.
This template prefers inline formatting of parameters.
Kipengele
Maelezo
Aina
Hali
Value
1
The value to convert.
Namba
hitaji
From unit
2
The unit for the provided value.
Mfano
km
Kishazi
hitaji
To units
3
The units to convert into. Separate units by a space for multiple outputs. In an output unit, use + for a multiplication space.
Mfano
mi nmi
Kishazi
pendekezo
Precision or suffix
4
Significant digits after decimal dot or, if negative, exponent of ten.
Namba
hiari
Link units
lk
Indication of what units to apply wikilinks to. Use “on” for all, “in” for the input unit, “out” for the output units, or “off” for none of the units.
Chaguomsingi
off
Mfano
on
Kishazi
hiari
Abbreviation
abbr
Display for the units: “on” to display all units using their unit symbols, “off” to display all units in full words, “in” to display the unit symbol for the input unit, “out” to display the unit symbols for the output units, “unit” to display unit symbols for both input and output units when using scientific notation, “values” for no units at all (neither unit symbols nor full words of units).
Chaguomsingi
out
Mfano
on, unit, in, out, off
Kishazi
pendekezo
Spelling
sp
Spelling of units. Use “us” to display unit names using U.S. spelling.
Mfano
us
Kishazi
hiari
Adjective
adj
Whether to use adjectival form. Use “on” for singular unit name appended by a hyphen, “mid” to put conversion at end, or “off” (default) for no adjectival form.
Chaguomsingi
off
Mfano
on
Unbalanced wikitext
hiari
Conversion
disp
Display conversion result: “or”: after ‘or’, “x”: with custom prefix and suffix, “b”: in parentheses, “table”/“tablecen”, “output only”: alone, “output number only”: alone and without unit, “unit”: not at all but input unit; if the value is a number it is used as precision.
Mfano
b
Kishazi
hiari
Ordering
order
“flip” returns converted value first, input value second.
Mfano
flip
Kishazi
hiari
Significant figures
sigfig
Indicates the number of significant figures to be used in rounding.
Namba
hiari
Rounding output
round
The type of rounding. “5” rounds the output number to nearest multiple of 5, “25” to nearest multiple of 25, “each” rounds each number in a range.
Namba
hiari
Thousands separator
comma
Sets or suppresses the use of thousands separators in the numbers. “off”: no separator; “gaps”: use space instead of comma as thousands separator; “5”: only add thousands separator when the integral part of the number uses 5 positions or more (10,000 or more; if using comma as thousands separator, 1234 would produce '1234', 12345 would produce '12,345').
Chaguomsingi
on
Mfano
off
Kishazi
hiari
Sort key
sortable
“on” generates a hidden sort key
Mfano
on
Kishazi
hiari
Spell numbers?
spell
If used, spells input or input and output numbers in words, optionally capitalizing the first
Mfano
'in', 'In', 'on', or 'On'
Kishazi
hiari
Singular?
sing
If 'yes', uses singular form of units (deprecated)
Mfano
yes
Kishazi
siyo hai
Fraction?
frac
fraction as rounding unit
Namba
hiari
Currency symbol
$
sets currency symbol in both units
Mfano
$=€ will show " €10 per mile (€6.2/km)"
Kishazi
hiari
WD property
input
Reads the property value of the item (article), then converts it