Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

price-parser-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

price-parser-js

A powerful library that parses price and currency from text (string). Handles almost every case!

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

🏷️ price-parser-js

NPM Version Downloads

A powerful JavaScript library that extracts prices and currency from text! Handles multiple formats and edge cases.

🚀 Features

✅ Extracts price & currency from any text
✅ Handles $, €, £, ₹, ¥, and more
✅ Works with decimals, commas, and spaces
✅ Supports JavaScript & TypeScript

Installation

Install using npm:

npm install price-parser-js

Usage

const { extractPriceAndCurrency } = require("price-parser");

const result = extractPriceAndCurrency("$1233.54 CHF");
console.log(result); // { price: 1233.54, currency: "CHF" }

API

extractPriceAndCurrency(priceText)
// Parses a string to extract the price and currency.

Parameters

priceText (string) - The input text containing a price and currency.

Returns

{ price: number, currency: string | null }

Examples

extractPriceAndCurrency("€1.234,99");  // { price: 1234.99, currency: "€" }
extractPriceAndCurrency("1233.54 CHF");  // { price: 1233.54, currency: "CHF" }
extractPriceAndCurrency("$1,233.54");  // { price: 1233.54, currency: "$" }
extractPriceAndCurrency("JPY 1000");   // { price: 1000, currency: "JPY" }
extractPriceAndCurrency("1000 GBP");   // { price: 1000, currency: "GBP" }
extractPriceAndCurrency("No price here"); // { price: null, currency: null }

License: MIT

Keywords

price

FAQs

Package last updated on 29 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts