Weight
The weight category provides conversions between metric units (grams, kilograms, tonnes) and Imperial/US units (ounces, pounds, stones, tons).
Supported Units
Section titled “Supported Units”- Metric: milligram (mg), gram (g), kilogram (kg), tonne (t)
- Imperial / US: ounce (oz), pound (lb), stone (st), ton (US ton)
Quick Example
Section titled “Quick Example”import { Conversion } from "@devhaven/unit-conversion";
const convert = new Conversion();
console.log(convert.value(1000).from("gram").to("kilogram")); // "1kg"console.log(convert.value(1).from("pound").to("kilogram")); // "0.454kg"
Common Conversions
Section titled “Common Conversions”Gram ↔ Kilogram
Section titled “Gram ↔ Kilogram”convert.value(1000).from("gram").to("kilogram"); // "1kg"convert.value(1).from("kilogram").to("gram"); // "1000g"
Ounce ↔ Pound
Section titled “Ounce ↔ Pound”convert.value(16).from("ounce").to("pound"); // "1lb"convert.value(1).from("pound").to("ounce"); // "16oz"