unit converter with focus on type-safety, simplicity and performance.
const converted = units.from(3, "cm").to("in");
console.log(converted);
// Output: 1.1811
const c1 = units.Convertible(100, "kilometer");
const c2 = units.Convertible(1000, "meter");
if (c1.lt(c2)) {
console.log(`${c1} is less than ${c2}!`);
} else if (c1.eq(c2)) {
console.log(`${c1} and ${c2} are equal!`);
} else {
console.log(`${c1} is greater than ${c2}!`);
}
// Output: 100km is greater than 1000m!
const convertible = units.Convertible(12.2323123, "kt");
console.log(convertible.format("%.2f %s", { length: "long" }));
// Output: 12.23 knots
Read useful guides here. Read the full documentation here.
| unit | synonyms | % |
|---|---|---|
| %0m² | %0m^2, %0m2, square %0meter, sq %0meter, sq %0metre, square %0metre, square %0meters, sq %0meters, sq %0metres, square %0metres |
0: SI-Prefixes from |
| %0a | %0are, %0ares |
0:
|
| in² | ″², in^2, ″^2, ″2, in2, square inch, sq inch, square inches, sq inches |
- |
| ft² | ft^2, ft2, square foot, sq foot, square feet, sq feet |
- |
| mi² | mi^2, mi2, square mile, sq mile, square miles, sq miles |
- |
| yd² | yd^2, yd2, square yard, sq yard, square yards, sq yards |
- |
| ac | acre, acres |
- |
| unit | synonyms | % |
|---|---|---|
| %0A | %0ampere, %0ampere |
0: SI-Prefixes from |
| unit | synonyms | % |
|---|---|---|
| %0B | %0byte, %0bytes |
0:
SI-Prefixes from |
| %0b | %0bit, %0bits |
0:
SI-Prefixes from |
| unit | synonyms | % |
|---|---|---|
| %0J | %0joule, %0joule, %0joules |
0: SI-Prefixes from |
| %0W%1 | %0watt-%1, %0watt-%1 |
0: SI-Prefixes from 1: h (hour, hours), s (second, seconds) |
| %0eV | %0electronvolt, %0electronvolts |
0: SI-Prefixes from |
| %0cal | %0calorie, %0calories |
0: k (kilo) |
| erg | ergs |
- |
| unit | synonyms | % |
|---|---|---|
| %0N | %0newton |
0: SI-Prefixes from |
| unit | synonyms | % |
|---|---|---|
| %0m | %0meter, %0meters, %0metre, %0metres |
0:
SI-Prefixes from |
| in | ″, inch, inches |
- |
| yd | yard, yards |
- |
| ly | light-year, lightyear, light-years, lightyears |
- |
| ft | foot, feet |
- |
| mi | mi., mile, miles |
- |
| unit | synonyms | % |
|---|---|---|
| %0g | %0gram, %0gramme, %0grams |
0: SI-Prefixes from |
| %0mt | %0metric ton, %0metric tons |
0: SI-Prefixes from |
| t | ton, short ton, tons, short tons |
- |
| oz | oz av, ounce, avoirdupois ounce, ounces, avoirdupois ounces |
- |
| lb | lb av, pound, avoirdupois pound, pound-mass, pounds, avoirdupois pounds |
- |
| unit | synonyms | % |
|---|---|---|
| ppm | parts per million, part per million |
- |
| ppb | parts per billion, part per billion |
- |
| ppt | parts per trillion, part per trillion |
- |
| ppq | parts per quadrillion, part per quadrillion |
- |
| unit | synonyms | % |
|---|---|---|
| %0W | %0watt, %0watts |
0: SI-Prefixes from |
| %0J/%1 | %0joule/%1, %0joules/%1 |
0: SI-Prefixes from 1: All time units. |
| unit | synonyms | % |
|---|---|---|
| %0Pa | %0pascal, %0pascals |
0: SI-Prefixes from |
| bar | Bar, Bars |
- |
| torr | Torr, Torrs |
- |
| atm | standard atmosphere, standard atmospheres |
- |
| Mpsi | megapound per square inch, megapounds per square inch |
- |
| psi | lb. p. sq. in., psia, psig, pound-force per square inch, pound per square inch, pounds per square inch |
- |
| ksi | kilopound per square inch, kilopounds per square inch |
- |
| inHg | inch of mercury, inches of mercury |
- |
| unit | synonyms | % |
|---|---|---|
| %0m/%1 | %0meter/%1, %0metre/%1, %0meter per %1, %0metre per %1, %0meters/%1, %0metres/%1, %0meters per %1, %0metres per %1 |
0: SI-Prefixes from 1: Any time unit |
| ft/%0 | foot/%0, foot per %0, feet/%0, feet per %0 |
0: Any time unit |
| mi/%0 | mp%0, mile/%0, mile per %0, miles/%0, miles per %0 |
0: Any time unit |
| kt | kn, knot, knots |
- |
| Bft | Beaufort |
- |
| Ma | M, mach, Mach |
- |
| c | lightspeed, light-speed |
- |
| unit | synonyms | % |
|---|---|---|
| °C | degree Celsius, degrees Celsius |
- |
| °F | degree Fahrenheit, degrees Fahrenheit |
- |
| °R | degree Rankine, degrees Rankine |
- |
| K | Kelvin |
- |
| unit | synonyms | % |
|---|---|---|
| %0s | %0second, %0seconds |
0: SI-Prefixes from |
| min | minute, minutes |
- |
| h | hour, hours |
- |
| d | day, days |
- |
| wk | week, weeks |
- |
| mth | month, months |
- |
| a | year, years |
- |
| unit | synonyms | % |
|---|---|---|
| %0V | %0volt, %0volts |
0: SI-Prefixes from |
| unit | synonyms | % |
|---|---|---|
| %0m³ | %0m^3, %0m3, cubic %0meter, cubic %0meters, cubic %0metre, cubic %0metres |
0: SI-Prefixes from |
| %0l | %0liter, %0liters, %0litre, %0litres |
0: SI-Prefixes from |
| in³ | ″³, in^3, ″^3, ″3, in3, cubic inch, cubic inches |
- |
| ft³ | ft^3, ft3, cubic foot, cubic feet |
- |
| yd³ | yd^3, yd3, cubic yard, cubic yards |
- |
| c | cup, cups |
- |
| tsp | teaspoon, teaspoons |
- |
| tbsp | tablespoon, tablespoons |
- |
| fl oz | fl-oz, fluid ounce, fluid ounces |
- |
| qt | quart, quarts |
- |
| gal | gallon, gallons |
- |
Generated using TypeDoc