Is there are reputable and comprehensive unit conversion Javascript library? I do not want any libraries that makes AJAX calls to WolframAlpha or Google but something that does the calculation locally.
Asked
Active
Viewed 4,401 times
0
-
1Check this out: http://stackoverflow.com/a/3531444/864385 – Shawn31313 Jul 17 '13 at 03:01
-
2Check here http://stackoverflow.com/questions/865590/unit-of-measure-conversion-library – elclanrs Jul 17 '13 at 03:01
-
Nice one ;) @elclanrs – Shawn31313 Jul 17 '13 at 03:01
-
Possible duplicate of [Unit of Measure Conversion Library](https://stackoverflow.com/questions/865590/unit-of-measure-conversion-library) – Anderson Green Jun 29 '18 at 17:12
2 Answers
5
The math.js library comes with support for units. The library does not yet support derived units but that is on the planning.
Example usage:
math.evaluate('2 inch in cm');
math.evaluate('0.5kg + 33g');
math.evaluate('cos(45 deg)');

Jos de Jong
- 6,602
- 3
- 38
- 58
2
The library "measure" converts between unit types (volume, mass, etc.) and supports multiple unit systems (US, Imperial, Metric)
// volume
measure('1 teaspoon').teaspoons() // 1
measure('1 1/2 tsp.').teaspoons() // 1.5
measure('2 cups and 1 pint').quarts() // 1
// mass
measure('1 pound').ounces() // 16
measure('1 1/2 oz.').ounces() // 1.5
// operations
measure('1 teaspoon').add('1 teaspoon').teaspoons();
measure('6 1/2 teaspoon').divide(2).teaspoons(); // 3.25

strictlyk3v
- 562
- 5
- 7