Scratchpad:Convert

Template convert is used to convert a value from one unit of measurement to another. This page provides an overview of the options available when using the template.


 * Help:Convert units • Simplified list of some commonly used units
 * Help:Convert messages • Error and warning messages

Asking questions

 * Template talk:Convert • Questions on using the convert template, or discussion of any problems encountered
 * Help desk • General questions
 * Module talk:Convert • Discussion concerning the convert modules

Units

 * Help:Convert units • Simplified list of some commonly used units
 * Module:Convert/documentation/conversion data/doc • Full list of units

Quick start
By default, the name of the input unit is shown, while the output is abbreviated using the unit's symbol. If wanted, names or symbols can be used, and the output precision can be specified.
 * → 123.4 ft
 * → 123.4 ft
 * → 123.4 ft
 * → 123.4 ft
 * → 123.4 ft
 * → 123.4 ft

To avoid overlinking, units are not normally linked, but they can be when needed.
 * → 12300 m2
 * → 12300 m2

A convert can be used in an adjectival phrase, and user-specified text can be inserted.
 * → 1500 ft
 * → 1500 ft

If no output unit is specified, a default is used.
 * → 123.4 ft
 * → 123.4 ft
 * → 1500 ft

The last example used  to explicitly show that the output unit has been omitted. If that is not done, the result is an error, and holding the mouse over the error message shows that " " is misinterpreted as the output unit.
 * → 1500 ft

The input and outputs can be "flipped". When flipped, an option such as out means "link the right-hand side".
 * → 12300 m2
 * → 12300 m2
 * → 12300 m2

The input value can be spelled.
 * → 5 mi
 * → 5 mi

Ranges of values are supported.
 * → 3 - 6 ft
 * → 3 to 6 ft

A range can use more than two values.
 * → 100 x
 * → 100 x
 * → 100 by

Some input units consist of multiple components.
 * → 5 ft
 * → 11 st

An output can be a combination of several units.
 * → 123 nmi
 * → 123 hPa

Some outputs consist of multiple units.
 * → 123.4 m
 * → 123.4 kg

Rounding
By default, the output value is rounded to adjust its precision to match that of the input. An input such as 1234 is interpreted as 1234 ± 0.5, while 1200 is interpreted as 1200 ± 50, and the output value is displayed accordingly, taking into account the scale factor used in the conversion.

If the default is not wanted, the precision of output values can be specified using:
 * (where  is a number) to specify the number of digits to be displayed after the decimal mark (round output to N decimal places).
 * (where  is a negative number) to specify the number of digits before the decimal mark that should be replaced with zero (round output to nearest 10N).
 * (where  is a positive number) to specify the number of significant digits (round output to N significant figures).
 * to round the output to the nearest multiple of 5. The  value can be 0.5, 5, 10, 25 or 50.

Examples:
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1230 ft
 * → 1230 ft
 * → 1230 ft
 * → 5670 sqft
 * → 5670 sqft
 * → 7x8x12 ft

An input value such as 5000 is assumed to have one significant figure, while 5001 has four. If wanted, "5000." can be used to specify an input number that has four significant figures.
 * → 5000 m
 * → 5000. m

Spell
Use us to specify that unit names should be displayed with US spelling:
 * Use US (en-US) spelling for unit names
 * → 6 km
 * → 6 km

Use in to specify that the input value should be spelled in words, or In (uppercase " ") to start with an uppercase letter:
 * Spell out numbers in words
 * → 5 mi
 * → 5 mi
 * → 5 mi
 * → 5 mi
 * → 2+1/4 mi
 * → 2+1/4 mi

The input and output can be "flipped", as shown in these examples. Logically, the resulting first number is spelled: The " " provides an empty output unit to mean "use the default".
 * → 5 mi
 * → 5 mi

Both input and output values can be spelled:
 * → 5 mi
 * → 5 mi

Thousands separator
Commas in input numbers are ignored. Gaps are not allowed in input.

In output, by default, the thousands separator is the comma: Set off to remove separators from the result:
 * → 1234567 m
 * → 1,234,567 m
 * → 1,234,567 m

Setting 5 adds a separator only when the number of digits is 5 or more:
 * → 1234 m
 * → 1234 m
 * → 12345 m

Set gaps to use a small space for thousands grouping. If the resulting number is copied, only the digits are copied (the gaps are omitted).
 * → 1234567 m
 * → 1234567 m

Gaps are inserted on both sides of the decimal mark. However, by default, no gap is inserted before a single digit. If a gap is always wanted, gaps3 can be used.
 * → 1234.98765 m
 * → 1234.98765 m
 * → 1234.9876 m
 * → 1234.9876 m
 * → 1.2349876 m
 * → 1.2349876 m

Fractions
An input value can be specified as a fraction.
 * → 1/2 in
 * → 1/2 in
 * → 2+1/2 in
 * → -2-1/4 in
 * → 1/2 in

If two slashes are used, a horizontal fraction bar is used.
 * → 1//2 in
 * → 2+1//2 in

An output can be expressed with a fraction using  where N is the denominator. For example,  rounds the output to the nearest eighth.
 * → 219 mm
 * → 219 mm
 * → 219 mm
 * → 219 mm
 * → 222 mm

A fraction is applied to the output unit (if there is only one), or to non-SI units (if using a combination), except that if a precision is also specified, the fraction only applies to the hand unit.
 * → 18.45 in
 * → 18.45 in
 * → 18.45 in

Joins
The disp ("display") option may be used to "join" the input and output, as shown in the following examples.

Ranges
A range of values can be specified, as shown in the following examples.

Ranges can use more than two values.

Ranges can be specified in the first parameter.

Extra words
Some options provide text that is included in the output, as shown in the following examples.

In each of the above examples, " " provides an empty output unit which causes the default output to be used. An output unit, possibly empty, must be specified to avoid the template interpreting the extra text as the output unit. For example, using  has the same effect as using , namely that an error would occur because " " would be used as the output unit. The following illustrates the error (hover the mouse over the error text to see that the problem is due to " " ) and how it may be avoided.
 * → 4 ft
 * → 4 ft
 * → 4 ft
 * → 4 ft

Displaying parts of a conversion
The following examples show how to display only a part of the output.

Flipping the order of output
To invert the order of measurements, simply use flip
 * &rarr; 10 km (default)
 * &rarr; 10 km

Wrapping and line breaking
Convert uses the regular space (" ") and non-breaking space ( which shows: " ") to control line-breaking (also called wrapping/nowrapping).


 * In all examples below, an   is shown as "" (red underscore): " ".

Wrapping is possible where a regular space (" ") is used. Prevent wrapping is enforced in the template using the non-breaking space, that ties and keeps text elements together.
 * may break after "3"
 * , or 3 ft, will not break after "3"
 * A line break forces a newline (line break), and so overrules any nowrap setting at that point.

Word meaning:
 * In measurements, SI uses wording that says that value = number &times; unit, for example length = number &times; meter.''
 * In documentation, sometimes 'value' is uses to mean the number; and abbr is used to mean unit symbol(s).

The separator between the number and the unit can be a space or a nonbreaking space :
 * Within a single measured value (number and unit)
 * When a unit is abbreviated (symbol is shown), the separator is.
 * → 12 m


 * When a unit is not abbreviated (name is shown), the separator is a space.
 * → 12 m
 * This can be set (overruled) to be  by j (for 'join').
 * → 12 m


 * Some units do not have a symbol and always use a space (such as acre).
 * → 3 acre


 * Except, option  ("join") forces the number-unit separator (space) to be.
 * → 3 acre


 * Except,  is always used when a measurement is in multiple units.
 * → 1 ft
 * → 2 m


 * Except, if option  is used and the unit is not abbreviated, the separator is a hyphen ("-").
 * → 2 m


 * When the name of a number is used,  is used as the separator between the number and the name. For example, a measurement spelled as "12 million metres" has   before "million" and a space afterwards.
 * → 12 e6m


 * Between measurements
 * A space is used as the separator in a join between the first and second measurement.
 * → 3 ft


 * Except for the special case before "["&thinsp;:
 * → 12 in ( before "[")


 * Multiple output measurements (by listing units) always use a space between measurements ("; " has a space after ";").
 * → 2 acre


 * Between components of a measurement (e.g., in a range; between foot–inch)
 * A measurement in multiple units always uses a space between components ("1 foot 6 inches" has  before the unit names, but a space after "foot").
 * → 1 ft


 * In a range, spaces are generally used to separate items. For example, "to" and "or" have a space before and after in the following.
 * → 12 to 20 in
 * → 12 or


 * The ranges  and   always use  :
 * → 12 +/-
 * → 12 ,


 * The "to-" range (same as "to(-)") is an exception. When a unit is not abbreviated, "to" has  before and a space after.
 * → 12 to-


 * The "x" range is an exception. When a unit is abbreviated, "×" has a space before and  after.
 * → 12 x


 * Overrule by setting a line break
 * Parameter br adds a forced line break between measurements; brackets are omitted.
 * → 12 metres39 feet shows:
 * 12 m

To see the wikicode result of the convert template: put your  code into Special:ExpandTemplates and then preview by clicking.
 * Preview wikicode

Tables
The following parameters are intended for use in tables.

The following shows the wikitext output by some example converts.

Fixed table
This wikitext:

produces this table:

Sortable table
This wikitext:

produces this table:

Units in singular or plural
Unit symbols are always singular. Unit names can be singular or plural. A unit is singular when the number is exactly +1:
 * &rarr; 0.5 ft
 * &rarr; 1 ft
 * &rarr; 2 ft
 * Note: as of November 2014, in certain conditions this topic can behave unexpected (bug).

Setting 1 makes these values singular: (−1 <= v and v < 0) or (0 < v and v <= 1)
 * &rarr; 2 ft
 * &rarr; 1 ft
 * &rarr; 0.5 ft
 * &rarr; 0 ft
 * &rarr; -0.5 ft
 * &rarr; -1 ft
 * &rarr; -2 ft

Complicated grammar
This example is from article Fort McHenry:
 * The American defenders had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons.

This result cannot reasonably be produced by. However, convert can be used to construct the required text.


 * Use with subst to insert the required wikitext into the article or your sandbox.
 * → had 18, cannons
 * When the edit is saved, the convert template is replaced with the result.
 * Edit the result to produce the final text.
 * → had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons
 * → had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons

An alternative to subst would be to enter  into Special:ExpandTemplates, then copy and edit its result into the article.

Limitations
This is a list of features that the module may be expected to support, but which will not work.

Composite units cannot be used in a range:
 * → 2 ft

If an expression is wanted, it has to use :
 * → 3*12 ft
 * → undefined ft