DEV Community

Madhushan
Madhushan

Posted on

moneyify: A cashify-compatible currency converter with built-in live rates

If you've ever used cashify, you know the appeal: a tiny synchronous API for converting money, with expression parsing ("10 USD to EUR") and optional big.js precision.

The catch is that cashify stops there — you bring your own rates. In a real app, that means writing yet another fetch job, caching layer, and rate-refresh scheduler.

moneyify is a drop-in replacement that keeps the cashify API exactly the same, then adds one superpower: Moneyify.live() auto-fetches rates from the AllRatesToday API so you never need to maintain a rate table yourself.

What you get

  • 💡 Drop-in cashify replacement — same sync convert, same expression parsing, same big.js support
  • 🌍 Auto-fetch 160+ currencies from Refinitiv (Reuters) + interbank feeds
  • 📦 Zero runtime dependencies
  • 🧮 Optional big.js integration for arbitrary-precision math
  • 💬 Parses expressions: "10 USD to EUR", "€10 EUR in GBP", "1,250.5 usd in gbp"
  • 🟦 Written in TypeScript, ships ESM + CJS + .d.ts

Install

npm install moneyify
Enter fullscreen mode Exit fullscreen mode

1. Bring your own rates (identical to cashify)

import { Moneyify } from "moneyify";

const rates = { EUR: 1.00, GBP: 0.85, USD: 1.08 };
const m = new Moneyify({ base: "EUR", rates });

m.convert(10, { from: "EUR", to: "GBP" }); // 8.5
m.convert("10 EUR to GBP");                // 8.5
m.convert("€10 EUR in USD");               // 10.8
Enter fullscreen mode Exit fullscreen mode

If you're already a cashify user, that's exactly the code you're used to — migrating is a rename.

2. Auto-fetch from AllRatesToday (the moneyify moat)

import { Moneyify } from "moneyify";

// Rates are fetched and cached on construction.
const m = await Moneyify.live({
  base: "USD",
  apiKey: process.env.ALLRATESTODAY_API_KEY,
});

m.convert(100, { from: "USD", to: "INR" });  // e.g. 8320.5
m.convert("50 USD to EUR");                   // e.g. 46.17
Enter fullscreen mode Exit fullscreen mode

One call, fresh rates, no manual table maintenance. Get a free API key at allratestoday.com/register — no credit card required.

3. Functional style (also cashify-compatible)

import { convert } from "moneyify";

convert(10, {
  from: "EUR",
  to: "GBP",
  base: "EUR",
  rates: { GBP: 0.85, EUR: 1.0 },
}); // 8.5
Enter fullscreen mode Exit fullscreen mode

4. Parse expressions without converting

Useful for building chat bots, Slack commands, or any UI where users type free-form money strings:

import { parse } from "moneyify";

parse("10 EUR to GBP");      // { amount: 10, from: "EUR", to: "GBP" }
parse("€10 EUR");            // { amount: 10, from: "EUR" }
parse("1,250.5 usd in gbp"); // { amount: 1250.5, from: "USD", to: "GBP" }
Enter fullscreen mode Exit fullscreen mode

Supported separators: to, in, as (case-insensitive). Supported symbols: $, , £, ¥, , , , , , R$, A$, C$, HK$, NZ$, S$.

5. Precision math with big.js

Float drift becomes painful when you're adding up thousands of line items. Plug in big.js and precision is preserved:

import Big from "big.js";
import { Moneyify } from "moneyify";

const m = new Moneyify({
  base: "USD",
  rates: { EUR: 0.923456789 },
  BigJs: Big,
});

m.convert(100, { from: "USD", to: "EUR" }); // 92.3456789 (no float drift)
Enter fullscreen mode Exit fullscreen mode

Why moneyify instead of cashify?

Short answer: when you don't want to own the rate-fetching problem.

  • cashify — great library, but assumes you already have rates
  • moneyify — same API, plus a live() constructor that handles rates for you

If your app is already fetching rates from somewhere, stay on cashify. If you want one package that does conversion and rate fetching, moneyify is the simpler surface.

Next steps

Tried it out? Let me know what you built — expressions parser gotchas especially welcome.

Top comments (0)