Skip to content

henri228/parsecurrency

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parsecurrency

Build Status npm version

Node / browser currency parser.

Extensive currency parsing utility designed to extract value, decimal separator, group separator, currency symbol and iso code from currency string. It should work with most world currency formats except:

  • currencies with 3 decimals
  • currency with 2 character group separator (Swaziland Lilangeni)

Works with:

  • international currency formatting (SFr 12'345.67 or 10 000,00zł)
  • indian number system (₹1,50,000.00)
  • parsing CHF Swiss Franc (9'000.00 CHF)
  • currency symbols as a prefix / suffix with or without a space
  • currency code before or after the value, with or without space

Install

npm i parsecurrency --save

Example

const parseCurrency = require('parsecurrency');

const parsedCurrency = parseCurrency('$123,456.99USD');
// parsedCurrency =>
{
  "raw": "$123,456.99USD",
  "value": 123456.99,
  "integer": "123,456",
  "decimals": ".99",
  "currency": "USD",
  "symbol": "$",
  "decimalSeparator": ".",
  "groupSeparator": ","
}

More examples

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%