Simple browser-based currency converter built with vanilla JavaScript and Tailwind CSS. It fetches live exchange rates and converts an input amount between selected currencies.
- Live rates: Fetches latest rates from
exchangerate-api.com - Two-way selection: Choose both source (From) and target (To) currencies
- Instant result: Converts and displays the formatted output
- Responsive UI: Styled with Tailwind CSS
- HTML/CSS/JavaScript (no framework)
- Tailwind CSS v4 (via
@tailwindcss/cli)
index1.html: Main page and UI markupscript1.js: Logic to fetch currencies and perform conversioninput1.css: Tailwind entry file (imports Tailwind)output1.css: Built CSS consumed by the pagepackage.json: Tailwind CLI dependencies
- Node.js 18+ recommended
The repo already includes a compiled output1.css. You can open the app directly:
- Open
index1.htmlin your browser - Enter an amount, pick currencies, and click Convert
If you edit input1.css or want to regenerate output1.css, install dependencies and run the Tailwind CLI build:
cd currency_convertor
npm install
npx @tailwindcss/cli -i ./input1.css -o ./output1.css --minify- On page load, the app fetches
https://api.exchangerate-api.com/v4/latest/USDand populates the currency dropdowns - On Convert, it fetches
https://api.exchangerate-api.com/v4/latest/{FROM}to get the rate for{TO} - It multiplies the input amount by the selected rate and displays the result
- Network access: The app calls
exchangerate-api.com. If the API is down or rate-limited, conversion will fail. - Validation: Negative amounts are rejected; ensure you enter a non-negative number.
- CORS/Local files: Opening
index1.htmldirectly in a modern browser should work. If your browser blocks network calls from file URLs, serve the folder via a simple static server (e.g.,npx http-server .).
If FROM = USD, TO = EUR, and the rate is 0.92:
10 USD = 9.20 EUR
ISC (see package.json).