Currency conversion and money formating libraries in Javascript

money.js

These are 2 very useful Javascript libraries for dealing with money currency and formatting written by Joss Crowcroft.

Currency conversion with money.js

money.js is a currency conversion library with no dependencies, in just over 1 KB. You could provide your own currency rates in JSON format or use the data from the Open Source Exchange Rates project which is also created by Joss Crowcroft and looks very promising!

Usage examples:

// From any currency, to any currency:
fx.convert(12.99, {from: "GBP", to: "HKD"});

// Chaining:
fx(1000).from("USD").to("GBP");
fx(1000).to("AED");

// With simple settings and defaults, making this possible:
fx.convert(5318008);
fx(5318008).to("AED");

Money formatting with accounting.js

accounting.js is a small library for number, money and currency formatting, with optional excel-style column rendering (to line up symbols and decimals). It's lightweight, fully localisable and has no dependencies.

I've been using accounting.js for a month -in the administration panel of an e-commerce system- and had zero problems so far.

Usage examples:

// Default usage:
accounting.formatMoney(12345678); // $12,345,678.00

// European formatting (custom symbol and separators), could also use options object as second param:
accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99

// Negative values are formatted nicely, too:
accounting.formatMoney(-500000, "£ ", 0); // £ -500,000

// Simple `format` string allows control of symbol position [%v = value, %s = symbol]:
accounting.formatMoney(5318008, { symbol: "GBP",  format: "%v %s" }); // 5,318,008.00 GBP

// Formatting numbers
accounting.formatNumber(5318008); // 5,318,008
accounting.formatNumber(9876543.21, 3, " "); // 9 876 543.210

// Unformatting numbers / currency strings
accounting.unformat("£ 12,345,678.90 GBP"); // 12345678.9

Comments

Jason  •  March 6, 2013 03:49

accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99 -> this is useless.

Fredy  •  October 4, 2013 12:07

@Jason
I think you do not see the big picture

if you replace the 4999.99 by a variable then this function is very useful

Ermir  •  April 28, 2014 13:42

Hey thanks for this great information :) Was a pleasure reading it :)

obat perangsang wanita  •  June 24, 2014 12:00

wanita sedikit bingung disaat hubungan seksualnya sudah berkurang maka dari itu mereka takut jika pasangannya berpaling darinya oleh karena itu ini saat yang tepat dan cepat membangkitkan libido dengan obat perangsang wanita herbal alami dan sangat aman.

sara  •  November 3, 2014 08:13

Forex trading is open 24 hours a day and therefore you need to ensure that the forex broker that you choose operates at all times of the day. 

Forex Trading Platform

ace maxs  •  December 10, 2014 09:56

thanks for sharing mr

Portal Medan  •  December 26, 2014 17:00

This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.
http://www.caramakan.com | http://wahyublahe.com | http://merdekawalk.com | http://www.ceritamedan.com | http://www.22jerseybola.com | http://ceritamedan.blogdetik.com | http://inimedan.com | http://nasutionrizky.com | http://tamvanseo.blogspot.com | http://medanheritage.com | http://wahyublahe.blogspot.com | http://www.ceritamedan.com/2014/09/Pancake-Durian.html

http://goo.gl/SvFXl4 Social Media Buzzer | http://goo.gl/OgqOHo Cara Membuat Paspor Online | http://goo.gl/KGDkqN Manfaat Mandi Pagi | http://goo.gl/qYsBRi Cara Cek Nomor HP | http://goo.gl/l7uCgL Jasa SEO Medan | http://goo.gl/kFlME0 Cara Pakai Tongsis | http://goo.gl/O43aib Gaya Pacaran Anak Muda | http://goo.gl/1s6xwm Desain Kamar Tidur Anak Perempuan |

http://goo.gl/pAO4gM Cara Menurunkan Berat Badan | http://goo.gl/sfA5RT Foto Selfie | http://goo.gl/YVD20z Cara Menulis Cerita Fiksi | http://goo.gl/IMYXbC Manfaat Air Putih | http://goo.gl/kVbVxJ Parfum Pria | http://goo.gl/KGMUVR Kunci Jawaban Tebak Gambar | http://goo.gl/Dyh1zw Wisata Medan | http://goo.gl/wsViV0 Transportasi Medan | http://goo.gl/HuKSTI Pelaruga | http://goo.gl/uNLn51 Kuliner Medan | http://goo.gl/OKb0IJ Komunitas Medan | http://goo.gl/k1vK9X Berita Komunitas | http://goo.gl/98iCdo Oleh Oleh Khas Medan |
http://goo.gl/kWYmnK | http://goo.gl/ATnmhV Toko Roti di Medan | http://goo.gl/51UapI Cara Menjadi Barista | http://goo.gl/nurVHd Cara Menjadi Kaya | http://goo.gl/3LeXRA Cara Menjadi Model | http://goo.gl/4FQYi9 Cara Menjadi Ibu yang Baik | http://goo.gl/EqsY7i Tips Menjadi Penulis Hebat | http://goo.gl/3nJnZl Kopi Medan | http://goo.gl/4VQsNE Pulau Siba | http://goo.gl/Ey8A2h Daftar Film Bioskop Terbaru 2015 | http://goo.gl/MYEkbd Gaya Foto Prewedding

agen tiket pesawat  •  January 12, 2015 07:15

many thanks for share this

bisnis tiket pesawat  •  January 12, 2015 07:15

makasih atas info yang sangat menarik ini

usaha tiket pesawat  •  January 12, 2015 07:15

wow excellent content

dongdong32  •  January 23, 2015 16:41

http://lululemon.suleymanaltun.com
http://toms.raleighdowntowner.co
http://www.marc--jacobs.com
http://concord11.sellittodaywithebay.com
http://raybanwayfarer.thedailysabs.com
http://www.ralph-laurenoutlet.com.co
http://www.canadagoosejackets.name
http://www.lebronjames-shoes.net
http://www.louisvuittonhandbags.net.co
http://oakleysunglassescheap.oakleywebsite.net
http://christianlouboutinoutlet.maximumguarantee.com
http://www.jordan11.name
http://raybansunglasses.thedailysabs.com
http://www.lebronjames-shoes.name
http://www.fitflop-shoes.us
http://www.louis--vuitton.us
http://www.insanityworkout.com.co
http://truereligion.onlineinc.net.co
http://www.ugg-boots.eu.com
http://www.supra-shoes.cc
http://www.michaelkorshandbags.eu.com
http://knockoffwatches.freebirdspublishing.com
http://raybans.thedailysabs.com
http://www.ugg-boots.com.co
http://canadagoosejackets.pensacolacandles.com
http://www.toryburch-outletonline.com.co
http://www.ugg-boots.in.net
http://christianlouboutin.maximumguarantee.com
http://www.prada-outlet.us
http://oakleysunglasses.oakleywebsite.net
http://www.timberlandboots.cc
http://www.retrojordans.name
http://www.abercrombiekids.name
http://www.tory-burchoutlet.in.net
http://www.cheap-jordans.us.com
http://www.christian-louboutinoutlet.com.co
http://www.coach-outlet.us.com
http://www.celine-outlet.us
http://burberryoutlet.newestsite.net
http://www.hollisterkids.net
http://todsoutletstore.kingmancommercialrealestate.com
http://www.abercrombieandfitch.net.co
http://cheapoakleys.oakleywebsite.net
http://rayban.letterpresskids.com
http://www.polo-ralphlauren.net.co
http://www.louisvuitton-lvoutlet.com
http://tomswedges.raleighdowntowner.co
http://www.oakleysunglassescheap.name
http://www.truereligion.eu.com
http://www.louisvuittonoutlet.net.co

www.scorespro.com  •  January 28, 2015 06:17

All of us present the overall divisibility rule for any Divisor the industry prime quantity and put it on to particular cases. The reason is articulate and simple to follow, realize and utilize. www.scorespro.com

Post your comment

(optional)
(optional, will not be shown)
NOTE: Any links will have rel="nofollow"

back