UnitSwap
201 units across 17 categories — Length, Weight, Temperature, Volume, Speed, Data, Pressure, Energy & more
Launch UnitSwap →
Table of Contents
Overview
UnitSwap is a comprehensive unit conversion tool that handles 201 units organized across 17 categories, all running entirely in your browser with pure JavaScript arithmetic. From everyday conversions like miles to kilometers, to exotic physics units like Barns and Shakes, UnitSwap covers an extraordinary range of measurement systems used in science, engineering, cooking, computing, navigation, and daily life.
The converter uses a base-unit multiplication algorithm for 13 of its 17 categories: each unit has a conversion factor relative to a base unit, so converting between any two units is simply input × factor[from] ÷ factor[to]. The remaining categories require special treatment — Temperature uses custom non-linear formulas for all 8 scales (Celsius, Fahrenheit, Kelvin, Rankine, Réaumur, Delisle, Newton, and Rømer), and Fuel Economy handles the inverse relationship of L/100km where higher numbers mean less efficiency.
Every conversion happens in real time on every keystroke, with a formula bar showing the exact conversion equation (for example, "1 Mile = 1.609 Kilometers"), a quick reference table of 5 common pairs per category, bidirectional swap functionality, clipboard copy with visual feedback, and smart number formatting that automatically switches between standard notation, locale-formatted large numbers, and scientific notation for extreme values. There are zero external libraries, zero server calls, and zero data transmissions — just pure JavaScript math running on your device.
Key Features
17 Categories, 201 Units
Length (22), Weight (16), Temperature (8), Volume (18), Area (14), Speed (11), Data Storage (17), Time (13), Pressure (12), Energy (13), Power (11), Frequency (9), Angle (9), Fuel Economy (5), Force (8), Density (9), Torque (7) — every measurement domain covered.
8 Temperature Scales
Celsius, Fahrenheit, Kelvin, Rankine, Réaumur, Delisle, Newton, and Rømer — ALL non-linear with custom toC() and fromC() formulas. No simple multiplication here: each scale has its own unique mathematical relationship.
Fuel Economy Inverse Logic
L/100km uses inverted conversion: 100 ÷ value. Higher L/100km = LESS efficient. This correctly handles the "MPG Illusion" identified by Duke University research, where linear MPG improvements don't translate to linear fuel savings.
SI vs Binary Data Storage
KB = 1000 bytes (SI/marketing) vs KiB = 1024 bytes (binary/OS), plus Nibble (4 bits), Word (16-bit), DWord (32-bit), and QWord (64-bit) — settling the eternal debate of why your "500 GB" hard drive shows ~465 GiB.
Astronomical & Atomic Units
Light Year (9.461 × 10¹&sup5; m), Astronomical Unit (1.496 × 10¹¹ m), Speed of Light (299,792,458 m/s), Atomic Mass Unit (1.66 × 10&supmin;²&sup7; kg), and Electronvolt (1.602 × 10&supmin;¹&sup9; J) — from subatomic to cosmic scales.
Exotic Physics Units
Barn (Manhattan Project nuclear cross-section), Jiffy (Linux kernel timing), Shake (nuclear chain reaction step), Slug (Imperial FPS mass), and Poundal (British absolute force) — each with a fascinating origin story.
Formula Bar & Quick Reference
Live formula display shows the exact conversion equation (e.g., "1 Mile = 1.609 Kilometers"). Temperature shows actual computed values. Quick reference provides 5 common conversion pairs per category for instant learning.
Real-Time Bidirectional
Every keystroke converts instantly. The swap button exchanges both units AND values, maintaining conversion direction. Negative numbers are fully supported (critical for temperature). Scientific notation engages automatically for extreme values.
All 17 Categories
UnitSwap organizes its 201 units into 17 carefully curated categories. Here is every category with its unit count and notable units:
1. Length — 22 Units
Kilometer, Meter, Centimeter, Millimeter, Micrometer, Nanometer, Angstrom (10&supmin;¹° m), Mile, Yard, Foot, Inch, Nautical Mile (1,852 m), Fathom (1.8288 m), Furlong (201.168 m), Chain, Rod, Hand, Mil, Light Year (9.461 × 10¹&sup5; m), Astronomical Unit (1.496 × 10¹¹ m), Picometer, and Decimeter. Spans from subatomic Angstroms to interstellar Light Years — a factor of roughly 10²&sup5; between the smallest and largest units.
2. Weight — 16 Units
Metric Ton, Kilogram, Gram, Milligram, Microgram, Pound, Ounce, Troy Ounce (31.1 g, used for precious metals), Stone, Short Ton, Long Ton, Slug (14.594 kg, Imperial FPS system), Carat (0.2 g, gemstones), Grain (64.8 mg, smallest traditional unit), Quintal (100 kg), and Atomic Mass Unit (1.66 × 10&supmin;²&sup7; kg, mass of a proton).
3. Temperature — 8 Units
Celsius, Fahrenheit, Kelvin, Rankine, Réaumur, Delisle, Newton, and Rømer. ALL non-linear — every conversion requires a custom two-step formula through Celsius as the intermediate scale. See the dedicated Temperature section below for full formulas.
4. Volume — 18 Units
Cubic Meter, Liter, Milliliter, US Gallon, US Quart, US Pint, US Cup (236.59 mL), US Tablespoon (14.79 mL), US Teaspoon (4.93 mL), US Fluid Ounce, Imperial Gallon, Imperial Pint, Imperial Fluid Ounce, Imperial Quart, Cubic Foot, Cubic Inch, Cubic Yard, and Barrel of Oil (158.99 L). Includes both US Customary and Imperial variants, which differ significantly — a US pint is 473 mL while an Imperial pint is 568 mL.
5. Area — 14 Units
Square Kilometer, Square Meter, Square Centimeter, Square Millimeter, Hectare (10,000 m²), Acre (4,046.86 m²), Square Mile, Square Yard, Square Foot, Square Inch, Are (100 m²), Rood (1,011.71 m²), Barn (10&supmin;²&sup8; m², nuclear physics cross-section), and Square Rod. The Barn is the standout unit here — see Exotic Units for its Manhattan Project origin story.
6. Speed — 11 Units
Meters/Second, Kilometers/Hour, Miles/Hour, Feet/Second, Knot (0.514 m/s, nautical), Mach (343 m/s at sea level), Speed of Light (299,792,458 m/s), Centimeters/Second, Millimeters/Second, Inches/Second, and Yards/Second. Converting everyday speeds to fractions of the speed of light puts things in perspective — highway speed is roughly 0.00000009c.
7. Data Storage — 17 Units
Bit, Nibble (4 bits), Byte, Word (16-bit), DWord (32-bit), QWord (64-bit), Kilobyte (1,000 B), Kibibyte (1,024 B), Megabyte, Mebibyte, Gigabyte, Gibibyte, Terabyte, Tebibyte, Petabyte, Pebibyte, and Exabyte. The SI (powers of 1,000) vs binary (powers of 1,024) distinction is critical — a 1 TB hard drive marketed using SI units shows as ~931 GiB in your operating system.
8. Time — 13 Units
Nanosecond, Microsecond, Millisecond, Second, Minute, Hour, Day, Week, Fortnight (1,209,600 s or 14 days), Month (30.44 days average), Year, Century, and Millennium. Also includes Jiffy (0.01 s, electronics timing) and Shake (10&supmin;&sup8; s, nuclear physics). A millennium spans approximately 31.557 billion seconds.
9. Pressure — 12 Units
Pascal, Kilopascal, Megapascal, Bar, Millibar, Atmosphere (101,325 Pa), PSI (6,894.76 Pa), Torr (133.32 Pa), mmHg (millimeters of mercury), Inch of Mercury, Inch of Water, and Kilogram-force per square centimeter. Medical blood pressure is measured in mmHg, tire pressure in PSI, and weather in millibars or hectopascals.
10. Energy — 13 Units
Joule, Kilojoule, Megajoule, Calorie, Kilocalorie (food Calorie), Watt-hour, Kilowatt-hour, BTU (1,055.06 J), Therm (1.055 × 10&sup8; J), Electronvolt (1.602 × 10&supmin;¹&sup9; J), Erg (10&supmin;&sup7; J), Foot-pound, and Ton of TNT (4.184 × 10&sup9; J). Spans from the energy of a single photon (eV) to nuclear explosions (tons of TNT).
11. Power — 11 Units
Watt, Kilowatt, Megawatt, Gigawatt, Mechanical Horsepower (745.7 W, defined by James Watt in 1782), Metric Horsepower (735.5 W, based on metric units), Boiler Horsepower (9,809.5 W), BTU/hour, Foot-pound/second, Ton of Refrigeration (3,516.85 W), and Milliwatt. Three different definitions of horsepower can cause real confusion in engineering contexts.
12. Frequency — 9 Units
Hertz, Kilohertz, Megahertz, Gigahertz, Terahertz, RPM (revolutions per minute, 1/60 Hz), BPM (beats per minute, 1/60 Hz), FPS (frames per second, 1 Hz), and Radians per Second (1/2π Hz). Useful for audio engineering (Hz), engine tuning (RPM), music (BPM), gaming (FPS), and physics (rad/s).
13. Angle — 9 Units
Degree, Radian (57.2958°), Gradian (0.9°, used in surveying), Arcminute (1/60°), Arcsecond (1/3600°), Turn (360°), Milliradian (used in military optics), Quadrant (90°), and Sextant (60°). Radians are the natural unit for calculus and physics, while degrees dominate everyday use and navigation.
14. Fuel Economy — 5 Units
Kilometers per Liter, Miles per Gallon US (factor 0.425), Miles per Gallon UK (factor 0.354), Liters per 100 km (INVERSE relationship), and Miles per Liter. L/100km requires special inverse handling because it measures consumption rather than efficiency — see the dedicated Fuel Economy section below.
15. Force — 8 Units
Newton, Kilonewton, Meganewton, Dyne (10&supmin;&sup5; N, CGS unit), Pound-force (4.448 N), Kilogram-force (9.807 N), Gram-force, Poundal (0.138 N, British absolute unit), and Kip (4,448 N, 1000 pounds-force). The distinction between pound-force and poundal reflects the difference between gravitational and absolute force systems.
16. Density — 9 Units
Kilogram per Cubic Meter, Gram per Cubic Centimeter (1,000 kg/m³), Kilogram per Liter, Gram per Milliliter, Gram per Liter, Pound per Cubic Foot (16.02 kg/m³), Pound per Cubic Inch (27,680 kg/m³), Slug per Cubic Foot (515.38 kg/m³), and Ton per Cubic Meter. Water is exactly 1 g/cm³ at 4°C, making it the historical basis for the metric system.
17. Torque — 7 Units
Newton-meter, Kilonewton-meter, Millinewton-meter, Foot-pound force (1.356 N·m), Inch-pound (0.113 N·m), Kilogram-force meter (9.807 N·m), Ounce-force inch (0.00706 N·m), and Dyne-centimeter (10&supmin;&sup7; N·m). Torque is critical in automotive engineering, where engine output is measured in N·m (metric) or ft·lbf (imperial).
Temperature: 8 Non-Linear Scales
Temperature is the most mathematically complex category in UnitSwap. Unlike length or weight where every unit relates to a base by simple multiplication, temperature scales have different zero points and different degree sizes. UnitSwap solves this with a two-step conversion: first convert the input to Celsius using toC(), then convert from Celsius to the target scale using fromC().
The toC() Formulas (Any Scale → Celsius)
Fahrenheit → Celsius: C = (F − 32) × 5/9
The 32-degree offset and 5/9 ratio reflect that water freezes at 32°F/0°C and boils at 212°F/100°C.
Kelvin → Celsius: C = K − 273.15
Kelvin uses the same degree size as Celsius but starts at absolute zero (−273.15°C).
Rankine → Celsius: C = (Ra − 491.67) × 5/9
Rankine is to Fahrenheit what Kelvin is to Celsius — an absolute scale with Fahrenheit-sized degrees.
Réaumur → Celsius: C = Re × 5/4
Réaumur sets water's boiling point at 80°Re instead of 100°C, so each Réaumur degree is 1.25 Celsius degrees.
Delisle → Celsius: C = 100 − De × 2/3
An inverted scale: water boils at 0°De and freezes at 150°De. Higher values mean colder temperatures.
Newton → Celsius: C = N × 100/33
Isaac Newton's scale sets water's freezing at 0°N and boiling at 33°N.
Rømer → Celsius: C = (Rø − 7.5) × 40/21
Ole Rømer's 1701 scale starts at 7.5°Rø for water's freezing point and 60°Rø for boiling.
The fromC() Formulas (Celsius → Any Scale)
Celsius → Fahrenheit: F = C × 9/5 + 32
Celsius → Kelvin: K = C + 273.15
Celsius → Rankine: Ra = C × 9/5 + 491.67
Celsius → Réaumur: Re = C × 4/5
Celsius → Delisle: De = (100 − C) × 3/2
Celsius → Newton: N = C × 33/100
Celsius → Rømer: Rø = C × 21/40 + 7.5
The −40° Intersection
There is exactly one temperature where Celsius and Fahrenheit agree: −40°. This can be proven algebraically: set C = F in the formula C = (F − 32) × 5/9, which gives F = (F − 32) × 5/9, solve to get 9F = 5F − 160, therefore 4F = −160, and F = −40. UnitSwap correctly handles this and all negative temperature values.
Fuel Economy & The Inverse Problem
Fuel Economy is the second specially handled category in UnitSwap. Most fuel economy units (km/L, MPG US, MPG UK, Miles/Liter) measure efficiency — higher numbers mean better mileage. But L/100km measures consumption — higher numbers mean worse mileage. This inverse relationship requires special conversion logic.
The Algorithm
UnitSwap uses km/L as the internal base unit for fuel economy:
Converting FROM L/100km: kpl = 100 ÷ value (invert the consumption figure)
Converting TO L/100km: result = 100 ÷ kpl (invert back to consumption)
All other fuel economy conversions: Standard kpl = value × factor[from] and result = kpl ÷ factor[to]
Division by zero (entering 0 for L/100km) correctly produces infinity (∞), because a car that uses 0 liters per 100 km would have infinite efficiency.
The MPG Illusion
Research from Duke University revealed a cognitive bias called the "MPG Illusion": people intuitively think that improving from 10 to 20 MPG saves the same fuel as improving from 30 to 50 MPG. In reality, the 10-to-20 improvement saves far more fuel. Over 10,000 miles, going from 10 to 20 MPG saves 500 gallons, while going from 30 to 50 MPG saves only 133 gallons. This is because MPG has a non-linear (hyperbolic) relationship with actual fuel consumption. L/100km, despite being "inverted," is actually the more honest unit because it is linear with consumption. UnitSwap handles both perspectives correctly.
Exotic Units & Their Origins
Some of UnitSwap's 201 units have remarkable origin stories rooted in nuclear physics, naval tradition, and historical measurement systems:
Barn (10&supmin;²&sup8; m²) — Area
During the Manhattan Project in the 1940s, physicists working on nuclear reactions needed a unit for the cross-sectional area of atomic nuclei — the effective "target size" that determines how likely a neutron is to hit a nucleus. Uranium-235 nuclei, at roughly 10&supmin;²&sup4; cm², were so much larger than other nuclear targets that the physicists joked they were "as big as a barn." The name stuck and became an official unit in nuclear and particle physics. The formal definition is 10&supmin;²&sup8; m² or 10&supmin;²&sup4; cm². There are even sub-units: the millibarn, microbarn, nanobarn, picobarn, and femtobarn, regularly used at CERN.
Jiffy (0.01 seconds) — Time
In electronics, a jiffy is defined as 0.01 seconds (10 milliseconds), representing one AC power cycle at 50 Hz. The term has a deeper significance in computing: the Linux kernel defines a "jiffy" as the duration of one tick of its system timer, determined by the CONFIG_HZ compile-time constant (commonly 100, 250, or 1000 Hz). This makes a jiffy either 10 ms, 4 ms, or 1 ms depending on kernel configuration. The word "jiffy" predates its technical use — it first appeared in the 1780s as slang for "a very short time," possibly derived from the phrase "in a jiff."
Shake (10&supmin;&sup8; seconds) — Time
A shake is 10 nanoseconds — named from the expression "two shakes of a lamb's tail" to mean a very short time. In nuclear physics, it represents the approximate time for one step (one generation) in a nuclear chain reaction. During an atomic explosion, the entire chain reaction from start to full detonation occurs in about 50 to 60 shakes (500–600 nanoseconds). The unit was coined during the Manhattan Project, alongside the barn, as part of the informal but precise language that nuclear physicists developed.
Slug (14.594 kg) — Weight
The slug is the unit of mass in the Imperial foot-pound-second (FPS) system. It is defined so that a force of one pound-force accelerates a mass of one slug at one foot per second squared. This makes Newton's second law work cleanly in Imperial units: F = m × a with force in lbf, mass in slugs, and acceleration in ft/s². One slug equals approximately 14.594 kg or 32.174 pounds-mass. The name likely comes from the idea of a "sluggish" mass — a heavy, slow-moving object. Slugs are still used in aerospace engineering and fluid dynamics in the United States.
Poundal (0.138 N) — Force
The poundal is the British absolute unit of force in the foot-pound-second system. It is defined as the force required to accelerate a mass of one pound at a rate of one foot per second squared. Unlike the pound-force (which depends on gravitational acceleration), the poundal is a pure derived unit making it "absolute" rather than "gravitational." One poundal equals approximately 0.13826 N. It was introduced in 1879 to provide a coherent unit of force for the FPS system that did not depend on the local value of gravitational acceleration, which varies slightly across Earth's surface.
How to Use
- Open UnitSwap — Launch the converter and you will see 17 category pills displayed as a horizontal scrollable row with emoji icons and names. Scroll through them or click the category you need (Length, Weight, Temperature, Volume, Area, Speed, Data Storage, Time, Pressure, Energy, Power, Frequency, Angle, Fuel Economy, Force, Density, or Torque). The selected pill centers itself in the scroll area.
- Select Your Units — Choose the "From" unit from the left dropdown and the "To" unit from the right dropdown. Both dropdowns list every unit available in the selected category with its full name. The formula bar immediately updates to show the conversion relationship.
- Type a Value — Enter a number in the input field. Conversion happens instantly on every keystroke. The formula bar dynamically shows the exact equation, such as "1 Mile = 1.609 Kilometers." For temperature, it shows the actual computed values rather than the factor. Smart input filtering accepts digits, decimal points, minus signs, and scientific notation (e/E).
- Use the Swap Button — Click the swap button (↔) to reverse the conversion direction. This exchanges both the units AND the values simultaneously, so the previous result becomes the new input and the previous input becomes the new result. The formula bar updates accordingly.
- Check the Quick Reference — Expand the Quick Reference section below the converter to see 5 common conversion pairs for the currently selected category. This is a collapsible table that provides handy at-a-glance reference values for the most frequently needed conversions.
- Copy the Result — Click the copy button next to the result to copy the converted value to your clipboard. A visual checkmark (✓) confirmation appears for 1.2 seconds, confirming the copy was successful.
- Handle Special Cases — For temperature, enter negative values freely (−40°C = −40°F is a fun one to verify). For fuel economy, note that L/100km is inverted — entering a larger number produces a smaller km/L result. For extremely large or small values, the result automatically switches to scientific notation with 6 decimal places.
Frequently Asked Questions
toC() function converts the input from any scale to Celsius using that scale's specific formula. Then, the fromC() function converts from Celsius to the target scale. For example, Fahrenheit to Kelvin goes: C = (F − 32) × 5/9, then K = C + 273.15. This two-step approach handles all 56 possible scale-to-scale conversions (8 × 7) with just 14 formulas instead of 56.C = (F − 32) × 5/9, set C equal to F (since we want the intersection), giving F = (F − 32) × 5/9. Multiply both sides by 9: 9F = 5F − 160. Subtract 5F: 4F = −160. Divide by 4: F = −40. So −40°C is exactly −40°F. No other two standard temperature scales share a crossover point at such a "clean" number. It is a genuinely cold temperature — about the average January low in parts of interior Canada and Siberia.9.461000 × 10¹&sup5; for a light year in meters. For large numbers between 10&sup6; and 10¹&sup5;, results use locale-aware comma formatting for readability (e.g., "1,609,344" instead of "1609344"). For numbers in the normal range, results show 8 to 10 significant figures for precision. This formatting applies automatically — no user action is needed.parseInt, parseFloat, multiplication (*), and division (/) operations. There are zero external libraries loaded, zero API calls made, zero network requests sent, and zero data transmitted to any server. Your input values, selected units, conversion results, and browsing patterns stay entirely on your device. The application does not even use localStorage, cookies, or any form of persistent storage. It is one of the simplest possible privacy stories: numbers go in, numbers come out, nothing leaves your browser.Privacy & Security
UnitSwap is pure mathematics — every conversion is a multiplication, division, or formula calculation performed by your browser's JavaScript engine. No external APIs, no libraries, no server processing, and no data transmission. Your measurements, calculations, and values remain entirely on your device. This is one of the simplest privacy stories possible: input × factor ÷ factor = output. The conversion factors are hardcoded constants in the JavaScript source code. Temperature formulas are simple arithmetic expressions. The fuel economy inverse is a single division. There is literally nothing to send to a server even if one existed — just numbers multiplied by other numbers. Your unit conversions, the values you type, and the categories you browse are never recorded, tracked, or transmitted anywhere.
Ready to convert? 201 units across 17 categories, all running in your browser with zero data uploads.
Launch UnitSwap →Related
Last Updated: March 26, 2026