What this Unit Converter converts
Unit Converter takes one numeric value and maps it from a From unit to a To unit inside a single category. The six categories on the page are Length, Weight, Temperature, Area, Volume, and Speed — the keys in CATEGORY_ORDER, each rendered as a category pill. There is no file picker: inputFormats are a number and unit selectors, not uploads.
The default state is groupKey "length", fromUnit "meter", toUnit "kilometer", and inputValue "1". Results update live. A converted number is a helper output from the coded factors or temperature formulas. It is not a verified measurement, product spec, medical dose, engineering result, legal standard, or current currency value.
Available categories and units in this tool
Only UNIT_GROUPS keys listed in CATEGORY_ORDER appear in the UI. Unused tables are not an issue here: every group in that object is selectable. Cross-category conversion is not implemented — length cannot become area, and volume cannot become weight.
- Length (base: meter)
- Meter (m), Kilometer (km), Centimeter (cm), Millimeter (mm), Mile (mi), Yard (yd), Foot (ft), Inch (in).
- Weight (base: kilogram)
- Kilogram (kg), Gram (g), Milligram (mg), Pound (lb), Ounce (oz), Metric Ton (t).
- Temperature (via Celsius)
- Celsius (°C), Fahrenheit (°F), Kelvin (K). No multiplicative factor table.
- Area (base: square-meter)
- Square Meter (m²), Square Kilometer (km²), Square Centimeter (cm²), Hectare (ha), Acre, Square Foot (ft²), Square Inch (in²).
- Volume (base: liter)
- Liter (L), Milliliter (mL), US Gallon, US Quart, US Pint, US Cup, Tablespoon, Teaspoon.
- Speed (base: meter-per-second)
- Meter / second (m/s), Kilometer / hour (km/h), Mile / hour (mph), Knot (kn), Foot / second (ft/s).
How its conversion math and displayed precision work
For every category except temperature, convertValue multiplies the parsed number by the source unit’s factor to reach the group’s baseUnit, then divides by the destination unit’s factor. Those factors are static numbers in UNIT_GROUPS — not live constants from a standards API.
JavaScript Number is IEEE-754 floating point, so long decimal chains can differ by a last digit from a hand calculator. Display is roundSmart: non-finite values become an empty string; exact 0 becomes "0"; magnitudes ≥ 1000 use toLocaleString with maximumFractionDigits 6; magnitudes ≥ 1 use maximumFractionDigits 8; smaller finite values use toPrecision(8) and then strip trailing zeros with /\.?0+$/. Copied result text is that formatted string, including any locale grouping the browser inserts. Copied equation text is formatConversionLine: input, from label, equals, formatted result, to label.
The sidebar Quick checks call getQuickExamples with multipliers 1, 10, and 100 on the current input — they are scaled copies of the same conversion, not extra unit systems. The All units grid converts the same input from the From unit into every other unit in that group (the From unit itself is omitted).
Temperature and other category-specific behavior, if implemented
usesFormulaConversion is true only for temperature. convertTemperature first maps the input to Celsius: Fahrenheit uses (value − 32) × 5/9; Kelvin uses value − 273.15; Celsius is used as-is. It then maps out: Fahrenheit = Celsius × 9/5 + 32; Kelvin = Celsius + 273.15. There is no absolute-zero check. Negative Kelvin and other physically questionable temperatures convert mathematically.
Weight’s ton selector is Metric Ton (t) with factor 1000 on the kilogram base — not a US short ton or UK long ton. Volume gallons, quarts, pints, and cups are labeled US; tablespoon and teaspoon use the US milliliter-scale factors against liter even though those two labels omit “US”. The length mile factor is 1609.344 (international mile). These are the coded values, not a claim of certified metrology.
How to use the real controls
- Click a Category pill: Length, Weight, Temperature, Area, Volume, or Speed. handleGroupChange calls getDefaultUnitsForGroup (Weight → kilogram/gram, Temperature → celsius/fahrenheit, and so on). The typed number is not cleared.
- Type into the Value field (type="number", inputMode decimal, placeholder “Enter a number”). There is no Convert button; useMemo runs analyzeConversion whenever category, units, or the number change. Live result updates immediately.
- Optionally click a VALUE_PRESETS chip. Length: 1, 10, 100, 1609. Weight: 1, 5, 50, 100. Temperature: 0, 20, 37, 100. Area: 1, 10, 100, 1000. Volume: 1, 5, 250, 1000. Speed: 1, 10, 60, 100.
- Choose From and To. Length defaults Meter (m) → Kilometer (km).
- Click Swap units (aria-label). handleSwap exchanges From and To only. It does not write the previous result into the input.
- Tap a row under All units in length (the heading is “All units in ” plus the selected category in lowercase). Helper text is “Tap to set target”. Empty/invalid number shows “Enter a valid number to see all unit conversions in this category.”
- Read Live result, Converted value, Conversion summary (Category, From, To, Input, Result, Mode Live), and Quick checks (current input × 1, 10, and 100).
- Click Copy result to copy roundSmart text (Result copied for 1.5 seconds). Click Copy full equation to copy formatConversionLine (Equation copied). Both stay disabled while formatted is empty. Clipboard failure is silent.
- Click Reset converter to restore this category’s default From/To pair and set the input to "1". It does not change the selected category. There is no file import, history, or download.
Decimal values, negative values, and invalid input
convertValue parses with Number(rawValue). Number.isFinite must pass, or the UI shows “Please enter a valid number.” Period decimals, signs, leading-dot values such as .5, and exponent notation such as 1e6 are accepted by that parser. Grouping commas (1,000) and decimal commas (1,5) become NaN. Infinity is rejected because it is not finite.
Negatives are allowed in every category: a negative length or mass still runs through the factors. Empty input is a special case: Number("") is 0, so the left-hand live result can show a conversion of zero, but hasInput is false when the field is blank, so the right-hand panel shows the intro instead of Copy/Reset. The native number control may also block some keystrokes before they reach state.
Units this tool does not support
- No currency, live exchange rates, or historical FX.
- No custom units, compound units (N·m, kg/m³), or user-defined factors.
- No data-storage units and therefore no decimal vs binary prefix distinction (KB vs KiB).
- No pressure, energy, power, time-duration, angle, or frequency categories.
- No nautical mile, fluid ounce, imperial gallon, metric cup, US short ton, or UK long ton.
- No cups-to-grams or other density/recipe conversions — volume and weight stay in separate groups.
Measurement conversion versus currency, validation, or professional calculation
This page is a fixed-set unit mapper. It does not fetch rates, certify a scale, check a drawing tolerance, dose a medication, or price a currency pair. A result that looks like 37 °C or 250 mL is still only Number() plus a coded factor or convertTemperature — not proof that a thermometer, package, or lab instrument read that value.
Do not treat the output as engineering-grade accuracy, a legal unit definition, a medical or recipe instruction, or a substitute for the standard your workplace or regulator names. If you need SI brochure figures, ASTM/ISO rounding, or instrument uncertainty, use those sources. This helper does not apply measurement validation beyond “is this a finite number and are both units in the selected UNIT_GROUPS entry.”
Privacy and browser-processing boundaries
analyzeConversion runs in the browser. Values and unit keys are not POSTed to a conversion API. FileWorkflowShell uses processingMode local and the privacy note “Private by design · Calculations stay in your browser · No upload.” trackToolEvent fires tool_started on the first non-empty input and tool_success once per stretch until category change or reset; the identified payload includes TOOL_SLUG and category (groupKey), not the numeric input, formatted output, or unit identifiers. That is still first-party analytics metadata. Site assets, ads, clipboard permission, extensions, and shared devices remain outside this helper.
A short result-review checklist
- Confirm the category is the quantity you meant (volume vs weight; speed vs length).
- Read the From and To labels, especially US Gallon vs an imperial chart, and Metric Ton (t) vs a short/long ton.
- If a decimal comma or thousands separator failed, re-enter with a period decimal and no grouping.
- If another calculator disagrees by a last digit, compare IEEE-754 plus roundSmart (locale grouping, fraction caps, toPrecision(8)).
- For temperature, remember affine formulas via Celsius — not a single scale factor — and that negative Kelvin is not blocked.
- Treat Swap as selector exchange only; treat Reset as default units + input 1 in the current category.
- Copy the formatted number or equation if you need to paste it; this page has no history or file export.
When another DevToolKit tool is more appropriate
- Time Zone Converter — when the value is a civil clock in a listed IANA city. This page has no time zones and does not convert hours on a clock, only speed units such as km/h.
- Timestamp Converter — when the number is Unix seconds or milliseconds. Here Number() is a measurement magnitude inside UNIT_GROUPS, not an epoch.