
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Pure TypeScript unit conversion engine — 200 units across 20 categories, temperature formulas, smart rounding. Zero dependencies.
Pure TypeScript unit conversion engine for developers. Convert between 200 units across 20 measurement categories including length, weight, temperature, volume, area, speed, time, data storage, pressure, energy, frequency, force, power, angle, fuel economy, data transfer, density, torque, cooking, and typography -- all with zero dependencies.
Try the interactive tools at unitfyi.com -- unit converter, conversion tables, and category explorer.
npm install unitfyi
Works in Node.js, Deno, Bun, and browsers (ESM).
import { convert, conversionTable, getCategoryUnits, getOrderedCategories } from "unitfyi";
// Convert between any compatible units
const temp = convert(100, "celsius", "fahrenheit");
console.log(temp.result); // 212
console.log(temp.formulaText); // "°F = (°C × 9/5) + 32"
const length = convert(1, "mile", "kilometer");
console.log(length.result); // 1.6093
console.log(length.fromSymbol); // "mi"
console.log(length.toSymbol); // "km"
// Generate a conversion table
const table = conversionTable("kilogram", "pound");
// [[1, 2.2046], [5, 11.0231], [10, 22.0462], ...]
// Browse categories and units
const categories = getOrderedCategories();
console.log(categories.length); // 20
const lengthUnits = getCategoryUnits("length");
console.log(lengthUnits.length); // 20 (meter, km, cm, mm, ...)
JavaScript uses IEEE 754 double-precision floats. For most unit conversions this is sufficient, but temperature and very large/small values use smart rounding to avoid floating-point artifacts like 99.99999999996.
The engine applies magnitude-aware rounding:
| Magnitude | Precision | Example |
|---|---|---|
| >= 1,000 | 2 decimal places | 5,280.00 |
| >= 1 | 4 decimal places | 1.6093 |
| >= 0.01 | 6 decimal places | 0.453592 |
| < 0.01 | 10 decimal places | 0.0000000001 |
Temperature conversions use function-based formulas (not linear factors) to maintain exact results: °F = (°C * 9/5) + 32, K = °C + 273.15, etc.
The engine covers 20 measurement categories with a total of 200 units:
| Category | Units | Examples |
|---|---|---|
| Length | 20 | meter, kilometer, mile, foot, inch, yard, nautical mile, ... |
| Weight | 15 | kilogram, pound, ounce, gram, stone, metric ton, ... |
| Temperature | 4 | Celsius, Fahrenheit, Kelvin, Rankine |
| Volume | 15 | liter, gallon (US/UK), cup, tablespoon, fluid ounce, ... |
| Area | 10 | square meter, acre, hectare, square foot, ... |
| Speed | 8 | km/h, mph, m/s, knot, Mach, speed of light, ... |
| Data Storage | 16 | byte, KB, MB, GB, TB, PB, KiB, MiB, GiB, ... |
| Pressure | 8 | pascal, bar, atm, psi, mmHg, torr, ... |
| Energy | 10 | joule, calorie, kWh, BTU, eV, ... |
| Cooking | 8 | cup, tablespoon, teaspoon, fluid ounce, ... |
Learn more: Unit Converter · SI Base Units · Category Explorer
import { convert } from "unitfyi";
// All temperature conversions use exact formulas (not linear approximation)
const c2f = convert(0, "celsius", "fahrenheit");
console.log(c2f.result); // 32
console.log(c2f.formulaText); // "°F = (°C × 9/5) + 32"
const f2c = convert(72, "fahrenheit", "celsius");
console.log(f2c.result); // 22.2222
const c2k = convert(-40, "celsius", "kelvin");
console.log(c2k.result); // 233.15
// Rankine scale also supported
const f2r = convert(100, "fahrenheit", "rankine");
console.log(f2r.result); // 559.67
Learn more: Temperature Converter · Absolute Zero
import { conversionTable } from "unitfyi";
// Default values: [1, 5, 10, 25, 50, 100, 250, 500, 1000]
const table = conversionTable("meter", "foot");
for (const [meters, feet] of table) {
console.log(`${meters} m = ${feet} ft`);
}
// Custom values
const custom = conversionTable("celsius", "fahrenheit", [0, 20, 37, 100]);
// [[0, 32], [20, 68], [37, 98.6], [100, 212]]
Learn more: Conversion Tables · REST API Docs
import { getUnit, getCategoryUnits, getOrderedCategories } from "unitfyi";
// Look up a single unit
const meter = getUnit("meter");
console.log(meter?.name); // "Meter"
console.log(meter?.symbol); // "m"
console.log(meter?.category); // "length"
console.log(meter?.aliases); // ["metre", "meters", "metres"]
// List all units in a category
const tempUnits = getCategoryUnits("temperature");
// [{ slug: "celsius", name: "Celsius", symbol: "°C", ... }, ...]
// Get all 20 categories sorted by display order
const cats = getOrderedCategories();
for (const cat of cats) {
console.log(`${cat.icon} ${cat.name}: ${cat.description}`);
}
Learn more: All Units · OpenAPI Spec
| Function | Description |
|---|---|
convert(value, fromSlug, toSlug) -> ConversionResult | Convert a value between two compatible units |
conversionTable(fromSlug, toSlug, values?) -> [number, number][] | Generate a conversion table for a unit pair |
| Function | Description |
|---|---|
getUnit(slug) -> UnitInfo | null | Look up a unit by slug |
getCategoryUnits(categorySlug) -> UnitInfo[] | Get all units in a category |
getOrderedCategories() -> CategoryDef[] | Get all 20 categories sorted by display order |
| Class | Description |
|---|---|
UnknownUnitError | Thrown when a unit slug is not found |
IncompatibleUnitsError | Thrown when converting between different categories |
| Export | Description |
|---|---|
UNITS | Record of all 200 unit definitions |
CATEGORIES | Record of all 20 category definitions |
FORMULAS | Non-linear conversion formulas (temperature) |
import type {
UnitDef,
CategoryDef,
ConversionResult,
UnitInfo,
TemperatureFormula,
} from "unitfyi";
pip install unitfyi
See the Python package on PyPI.
Part of the FYIPedia open-source developer tools ecosystem — everyday developer reference and conversion tools.
| Package | PyPI | npm | Description |
|---|---|---|---|
| unitfyi | PyPI | npm | Unit conversion, 220 units -- unitfyi.com |
| timefyi | PyPI | npm | Timezone ops & business hours -- timefyi.com |
| holidayfyi | PyPI | npm | Holiday dates & Easter calculation -- holidayfyi.com |
| namefyi | PyPI | npm | Korean romanization & Five Elements -- namefyi.com |
| distancefyi | PyPI | npm | Haversine distance & travel times -- distancefyi.com |
Embed UnitFYI widgets on any website with unitfyi-embed:
<script src="https://cdn.jsdelivr.net/npm/unitfyi-embed@1/dist/embed.min.js"></script>
<div data-unitfyi="entity" data-slug="example"></div>
Zero dependencies · Shadow DOM · 4 themes (light/dark/sepia/auto) · Widget docs
MIT
FAQs
Pure TypeScript unit conversion engine — 200 units across 20 categories, temperature formulas, smart rounding. Zero dependencies.
We found that unitfyi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.