Skip to content

iamwujiabao/Unit-Converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit Converter

A lightweight, zero-dependency web application for converting between common units of measurement — no server, no build step required.

Features

  • Three conversion categories — Length, Weight, and Temperature
  • Instant results — conversions are calculated client-side in the browser
  • Swap button — reverse the From/To units in one click
  • Quick-fill chips — tap a common conversion to pre-fill and auto-convert
  • Keyboard support — press Enter in the value field to convert
  • Reset — clear the form and result with a single button

Supported Units

Category Units
Length Millimeter, Centimeter, Meter, Kilometer, Inch, Foot, Yard, Mile
Weight Milligram, Gram, Kilogram, Ounce, Pound
Temperature Celsius, Fahrenheit, Kelvin

File Structure

index.html    # Markup — page structure and UI
style.css     # Styles — layout, theme, and animations
script.js     # Logic — unit data, conversion functions, and DOM interactions
README.md     # This file

Getting Started

No installation or build process is needed. All three files must be kept in the same directory. Open index.html in a browser:

open index.html

Or serve the directory with any static file server (required if your browser blocks local file imports):

npx serve .
# then visit http://localhost:3000

Usage

  1. Select a category tab — Length, Weight, or Temperature.
  2. Enter the value you want to convert in the input field.
  3. Choose the From and To units using the dropdowns.
  4. Click Convert (or press Enter) to see the result.
  5. Use the button to swap the two units.
  6. Click a quick conversion chip to auto-fill a common conversion.
  7. Click Reset to start over.

How It Works

Conversions are performed by reducing the input to a common base unit and then scaling to the target unit — meters for length, grams for weight, and Celsius for temperature (using the standard algebraic formulas). All logic lives in script.js and runs entirely in the browser with no network requests.

Browser Support

Works in all modern browsers (Chrome, Firefox, Safari, Edge). No polyfills required.

About

A lightweight, zero-dependency web application for converting between common units of measurement — no server, no build step required.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors