{"id":41642,"library":"number-formatter","title":"number-formatter","description":"A lightweight and fast standalone JavaScript number formatter, version 1.2.0. It supports standard number formatting masks like '#,##0.00', custom grouping and decimal symbols, auto-rounding, and prefix/suffix (with restrictions). The library is less than 1.2 KB minified and has no dependencies. It is available as an npm package and via Bower, with UMD support (AMD, CommonJS, global). Key differentiators: tiny footprint, simple API, and flexible mask syntax. Not intended for scientific notation or date formatting.","status":"maintenance","version":"1.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/j-/number-formatter","tags":["javascript","number","format","formatter","currency"],"install":[{"cmd":"npm install number-formatter","lang":"bash","label":"npm"},{"cmd":"yarn add number-formatter","lang":"bash","label":"yarn"},{"cmd":"pnpm add number-formatter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only. CommonJS: const numberFormatter = require('number-formatter')","wrong":"const { numberFormatter } = require('number-formatter');","symbol":"numberFormatter","correct":"import numberFormatter from 'number-formatter'"},{"note":"CommonJS: the package exports the function directly as module.exports","wrong":"import { numberFormatter } from 'number-formatter'","symbol":"numberFormatter","correct":"const numberFormatter = require('number-formatter')"},{"note":"Browser: global variable 'numberFormatter' after including script","wrong":"<script>import numberFormatter from 'number-formatter';</script>","symbol":"numberFormatter","correct":"<script src=\"number-formatter.min.js\"></script>\n<script>var result = numberFormatter('#,##0.00', 1234.5);</script>"}],"quickstart":{"code":"import numberFormatter from 'number-formatter';\n\n// Basic formatting with comma grouping and two decimals\nconst result = numberFormatter('#,##0.00', 1234567.891);\nconsole.log(result); // \"1,234,567.89\"\n\n// Currency format with prefix and negative handling\nconst currency = numberFormatter('$ #,###.00', -1234567.89);\nconsole.log(currency); // \"$ -1,234,567.89\"\n\n// Custom grouping and decimal symbols (e.g., European style)\nconst european = numberFormatter('#.##0,00', 1234567.89);\nconsole.log(european); // \"1.234.567,89\"\n\n// Rounding to 4 decimal places\nconst piFormatted = numberFormatter('0.0000', Math.PI);\nconsole.log(piFormatted); // \"3.1416\"","lang":"javascript","description":"Shows basic usage of numberFormatter with different masks: comma grouping, currency, European separators, and rounding."},"warnings":[{"fix":"To force a single symbol as group separator, add a trailing dot: '#,###.'","message":"Single symbol treated as decimal separator, not group separator (e.g., '#,###' outputs '1234567,890' instead of '1,234,567')","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use concatenation: '$' + numberFormatter('#,##0.00', val) or numberFormatter('#,##0.00', val) + 'USD'","message":"Prefix/suffix cannot contain digits, dashes, or plus signs","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use npm install instead of bower install","message":"Bower support is deprecated and the package is best consumed via npm","severity":"deprecated","affected_versions":">=1.1.5"},{"fix":"Upgrade to >=1.1.2 which removes negative sign from zero results","message":"Zero value with negation mask may still show negative sign in older versions <1.1.2","severity":"gotcha","affected_versions":"<1.1.2"},{"fix":"Avoid using with very large/small numbers; consider using Number.prototype.toExponential or a dedicated library","message":"No scientific or engineering notation supported","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'0.00':21 '1.2':39 '1.2.0':13 'amd':59 'api':67 'auto':28 'auto-round':27 'avail':48 'bower':55 'commonj':60 'currenc':84 'custom':22 'date':78 'decim':25 'depend':45 'differenti':63 'fast':7 'flexibl':69 'footprint':65 'format':18,79,82 'formatt':3,11,83 'global':61 'group':23 'intend':73 'javascript':9,80 'kb':40 'key':62 'less':37 'librari':35 'lightweight':5 'like':20 'mask':19,70 'minifi':41 'notat':76 'npm':51 'number':2,10,17,81 'number-formatt':1 'packag':52 'prefix/suffix':31 'restrict':33 'round':29 'scientif':75 'simpl':66 'standalon':8 'standard':16 'support':15,58 'symbol':26 'syntax':71 'tini':64 'umd':57 'version':12 'via':54","created_at":"2026-06-04T18:53:23.689558+00:00","updated_at":"2026-06-04T18:53:23.689558+00:00","problems":[{"fix":"Use: const numberFormatter = require('number-formatter');","cause":"Incorrect import style (e.g., named import instead of default) or missing require","error":"TypeError: numberFormatter is not a function"},{"fix":"Add trailing dot to force group separator: '#,###.'","cause":"Single symbol mask like '#,###' is interpreted as decimal separator","error":"Expected output '1,234,567' but got '1234567,890'"},{"fix":"Ensure the second argument is a number: use parseFloat or Number conversion first","cause":"Non-numeric input string","error":"numberFormatter('#,##0.00', 'abc') returns NaN"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"http://mottie.github.com/javascript-number-formatter/","github":"git://github.com/j-/number-formatter","docs":null,"changelog":null,"pypi":null,"npm":"number-formatter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}