Convert Currency

Convert between currencies using the Frankfurter API for live exchange rates.

Code

Utilities
const res = await fetch(
  `https://api.frankfurter.app/latest?amount=${amount}&from=${from}&to=${to}`
);
const data = await res.json();
return `${amount} ${from} = ${data.rates[to]} ${to}`;

Parameters

Amount to convert.

Source currency code.

Target currency code.

Browser·fetch() may be limited by CORS

More JavaScript Snippets