WOLFRAM

UnitConvert[quantity,targetunit]

attempts to convert the specified quantity to the specified targetunit.

UnitConvert[quantity]

converts the specified quantity to SI base units.

Details

  • The targetunit can be a canonical unit or a Quantity expression.
  • When targetunit is a Quantity, the resulting output will have the same unit as targetunit.
  • A targetunit specification can also be one of the following unit systems: "SIBase", "SI", "Imperial", "Conventional" or "Metric".
  • UnitConvert can separately convert temperatures and temperature differences. Temperatures are also converted into temperature differences by interpreting them as differences with respect to absolute zero.
  • UnitConvert accepts TimeSeries, EventSeries, and TemporalData inputs and attempts to convert Quantity values to the specified targetunit.
  • UnitConvert accepts Association inputs and attempts to convert Quantity values to the specified targetunit.
  • An internet connection is required for conversion between currency units.

Examples

open allclose all

Basic Examples  (4)Summary of the most common use cases

Convert from miles to kilometers:

Out[1]=1

Convert a Quantity object to the appropriate SI base units:

Out[1]=1
Out[2]=2

Convert the speed of light to SI base units:

Out[1]=1

Convert to conventionally used units:

Out[1]=1
Out[2]=2
Out[3]=3

Scope  (8)Survey of the scope of standard use cases

UnitConvert operates on lists of Quantity expressions:

Out[1]=1
Out[2]=2

Convert Quantity expressions to their equivalent SI units:

Out[1]=1
Out[2]=2

Get the SI unit value of a physical constant:

Out[1]=1

Convert the values of a time series:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Convert the Quantity values of an association to SI base units:

Out[1]=1
Out[2]=2

Convert the unit of a QuantityDistribution expression:

Out[1]=1
Out[2]=2

UnitConvert accepts structured arrays like QuantityArray or SymmetrizedArray objects:

Out[1]=1
Out[2]=2

UnitConvert accepts Association specifications:

Out[1]=1

Applications  (4)Sample problems that can be solved with this function

Use UnitConvert to examine the value of a unit in the "SIBase" unit system:

Out[1]=1
Out[2]=2
Out[3]=3

Use UnitConvert to find the value of a unit derived from SI base units:

Out[1]=1
Out[2]=2
Out[3]=3

Find the range of masses in kilograms for different objects, from the universe to an electron:

Out[1]=1

Compare the volume of different barrel units:

Out[1]=1
Out[2]=2

Properties & Relations  (9)Properties of the function, and connections to other functions

The first argument of UnitConvert can be given as a unit string:

Out[1]=1
Out[2]=2

The targetunit specification can be a product or quotient of strings:

Out[1]=1
Out[2]=2

An independent unit can only be converted to itself and multiples or submultiples of itself:

Out[1]=1
Out[2]=2

The second argument of UnitConvert can be a MixedUnit specification:

Out[1]=1

The units given in a MixedUnit specification do not need to be ordered:

Out[2]=2

UnitConvert can convert mixed Quantity objects:

Out[1]=1
Out[2]=2

UnitConvert will automatically attempt to interpret an unknown unit string:

Out[1]=1
Out[2]=2
Out[3]=3

When the target unit is specified as a Quantity object, its magnitude will be ignored:

Out[1]=1
Out[2]=2

The "SIBase" unit for "InformationUnit" is "Bits":

Out[1]=1

The "SIBase" unit for "MoneyUnit" is "USDollars":

Out[2]=2

UnitConvert threads over lists:

Out[1]=1
Out[2]=2

Possible Issues  (4)Common pitfalls and unexpected behavior

UnitConvert will return $Failed for incompatible specifications, such as those between different unit dimensions:

Out[1]=1
Out[2]=2

UnitConvert[q,"SIBase"] typically converts all units to their SI base units:

Out[1]=1

For special cases where no SI unit is standard for the dimension, non-SI units are permitted in SI base form:

Out[2]=2
Out[3]=3
Out[4]=4

When converting from a temperature to a temperature difference, the result will be given as a temperature difference from absolute zero:

Out[1]=1
Out[2]=2

Conversions from temperature differences to temperatures are not permitted:

Out[1]=1
Wolfram Research (2012), UnitConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitConvert.html (updated 2024).
Wolfram Research (2012), UnitConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitConvert.html (updated 2024).

Text

Wolfram Research (2012), UnitConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitConvert.html (updated 2024).

Wolfram Research (2012), UnitConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitConvert.html (updated 2024).

CMS

Wolfram Language. 2012. "UnitConvert." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/UnitConvert.html.

Wolfram Language. 2012. "UnitConvert." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/UnitConvert.html.

APA

Wolfram Language. (2012). UnitConvert. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnitConvert.html

Wolfram Language. (2012). UnitConvert. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnitConvert.html

BibTeX

@misc{reference.wolfram_2025_unitconvert, author="Wolfram Research", title="{UnitConvert}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/UnitConvert.html}", note=[Accessed: 30-March-2025 ]}

@misc{reference.wolfram_2025_unitconvert, author="Wolfram Research", title="{UnitConvert}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/UnitConvert.html}", note=[Accessed: 30-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_unitconvert, organization={Wolfram Research}, title={UnitConvert}, year={2024}, url={https://reference.wolfram.com/language/ref/UnitConvert.html}, note=[Accessed: 30-March-2025 ]}

@online{reference.wolfram_2025_unitconvert, organization={Wolfram Research}, title={UnitConvert}, year={2024}, url={https://reference.wolfram.com/language/ref/UnitConvert.html}, note=[Accessed: 30-March-2025 ]}