{"id":14036532,"url":"https://github.com/Mottie/javascript-number-formatter","last_synced_at":"2025-07-27T03:32:14.061Z","repository":{"id":16609054,"uuid":"19363825","full_name":"Mottie/javascript-number-formatter","owner":"Mottie","description":"Lightweight \u0026 Fast JavaScript Number Formatter","archived":false,"fork":false,"pushed_at":"2019-08-16T23:36:05.000Z","size":82,"stargazers_count":142,"open_issues_count":11,"forks_count":37,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-25T14:19:35.101Z","etag":null,"topics":["currency","formatter","internationalization","javascript","number"],"latest_commit_sha":null,"homepage":"http://mottie.github.io/javascript-number-formatter/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mottie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-02T02:18:06.000Z","updated_at":"2024-11-25T20:26:05.000Z","dependencies_parsed_at":"2022-08-27T19:40:47.512Z","dependency_job_id":null,"html_url":"https://github.com/Mottie/javascript-number-formatter","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/Mottie/javascript-number-formatter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mottie%2Fjavascript-number-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mottie%2Fjavascript-number-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mottie%2Fjavascript-number-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mottie%2Fjavascript-number-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mottie","download_url":"https://codeload.github.com/Mottie/javascript-number-formatter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mottie%2Fjavascript-number-formatter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267294180,"owners_count":24065343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["currency","formatter","internationalization","javascript","number"],"created_at":"2024-08-12T03:02:01.315Z","updated_at":"2025-07-27T03:32:13.630Z","avatar_url":"https://github.com/Mottie.png","language":"JavaScript","readme":"# Javascript Number Formatter\n\nLightweight \u0026 Fast JavaScript Number Formatter\n\n[![Build Status][build-image]][build-url] [![NPM Version][npm-image]][npm-url] [![devDependency Status][david-dev-image]][david-dev-url] [![MIT][license-image]][license-url]\n\n## Introduction\n\nThis standalone number formatter\u003csup\u003e\u0026dagger;\u003c/sup\u003e is intended to be short and fast. As they are the main factors for a high performance JavaScript app. Development release is around 150 lines including license info, blank lines and comments. And production release is less than 2,000 bytes.\n\n```js\nformat( \"#,##0.####\", 1234567.890 );  // output: \"1,234,567.89\"\nformat( \"$ #,###.00\", -1234567.890 ); // output: \"$ -1,234,567.89\"\n\n// Added in v2.0.0\nformat( \"$ #,###.00\", -1234567.890, {enforceMaskSign: true});  // output: \"$ 1,234,567.89\"\nformat( \"$ -#,###.00\", -1234567.890, {enforceMaskSign: true}); // output: \"$ -1,234,567.89\"\nformat( \"$ +#,###.00\", -1234567.890, {enforceMaskSign: true}); // output: \"$ -1,234,567.89\"\nformat( \"$ +#,###.00\", 1234567.890, {enforceMaskSign: true});  // output: \"$ +1,234,567.89\"\n```\n\n\u0026dagger; Initial development release of this code was written by KPL and hosted at [Google Code](https://code.google.com/p/javascript-number-formatter/).\n\n## Features\n\n* Short, fast, flexible yet standalone.\n* Accept standard number formatting like `#,##0.00` or with negation `-000.####`.\n* Accept any country format like `# ##0,00`, `#,###.##`, `#'###.##` or any type of non-numbering symbol.\n* Accept any numbers of digit grouping. `#,##,#0.000` or `#,###0.##` are all valid.\n* Accept any redundant/fool-proof formatting. `##,###,##.#` or `0#,#00#.###0#` are all OK.\n* Auto number rounding.\n* Simple interface, just supply mask \u0026 value like this: `format( \"0.0000\", 3.141592)`.\n* Include a prefix \u0026amp; suffix with the mask.\n\n## Limitations\n\n* No scientific/engineering formatting.\n* Not for date or phone formation.\n* No color control.\n* \u003cdel\u003eNo prefix or suffix is allowed except leading negation symbol. So `$#,##0.00` or `#,###.##USD` will not yield expected outcome. Use `'$'+format('#,##0.00', 123.45)` or `format('#,##0.00', 456.789) + 'USD'`\u003c/del\u003e\n* The prefix or suffix *can not* include any numbers (`0-9`), dashes (`-`), or plus signs (`+`).\n\n## Format Symbols\n\n| Description   | Symbol | Summary |\n|---------------|--------|---------|\n| Mask symbols  | #0123456789+- | Mask symbols used for formatting the value. |\n| Placeholders  | #123456789    | Un-forced digit*; this optional digit will only show if it is required as a placeholder. |\n| Zero          | 0             | Forced digit; the digit will be shown whether or not the digit is relevant to the value. |\n| Signs         | +-            | Indicates a positive or negative value; visible depending on the value sign and the `enforceMaskSign` setting. |\n| Leftmost      |               | _Any_ non-mask symbol\u0026dagger; inside the mask will be set to represent a thousands separator. |\n| Rightmost     |               | _Any_ non-mask symbol\u0026dagger; inside the mask\u0026Dagger; will be set to represent the decimal separator. |\n| Prefix/Suffix |               | _Any_ non-mask symbol\u0026dagger; outside the mask. |\n\n\\* Non-zero mask digits (`1` through `9`) behave the same as the `#`.\u003cbr\u003e\n\u0026dagger; Anything not a digit, and not a `+`, `-` or `#`.\u003cbr\u003e\n\u0026Dagger; In the case where there is a trailing decimal or comma, it will be included in the mask, e.g. `#.` or `0,`.\n\n## Note\n\nWhen only one symbol is supplied, the library will always treat that symbol as a decimal. For example, `format( '#,###', 1234567.890)` will output `1234567,890`.\n\nTo force a single symbol to be used as a separator, add a trailing symbol. In this example, a period is added to the end of the mask - `format( '#,###.', 1234567.890)` - resulting in it being used as a decimal and forcing the first symbol to be the separator and return this output: `1,234,567`.\n\n## Installation\n\n### npm package\n\n    npm install --save number-format.js\n\n## Demos\n\nA demo/sample page with few examples is provided ([demo](http://mottie.github.io/javascript-number-formatter/)).\n\nAnd a jsFiddle was created to aid in testing: https://jsfiddle.net/Mottie/t2etyodx/\n\n[build-url]: https://travis-ci.org/Mottie/javascript-number-formatter\n[build-image]: https://travis-ci.org/Mottie/javascript-number-formatter.png?branch=master\n[npm-url]: https://www.npmjs.com/package/number-format.js\n[npm-image]: https://img.shields.io/npm/v/number-format.js.svg\n[david-dev-url]: https://david-dm.org/Mottie/javascript-number-formatter?type=dev\n[david-dev-image]: https://david-dm.org/Mottie/javascript-number-formatter/dev-status.svg\n[license-url]: https://github.com/Mottie/javascript-number-formatter/blob/master/LICENSE\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg\n\n## Recent Changes\n\nView the [complete change log here](https://github.com/Mottie/javascript-number-formatter/wiki).\n\n### v2.0.7 (2018-11-13)\n\n* Update typescript binding. See [issue #20](https://github.com/Mottie/javascript-number-formatter/issues/20).\n* Fix improper placeholder behavior. Updated Readme with format symbols table. Closes [issue #19](https://github.com/Mottie/javascript-number-formatter/issues/19).\n* Add more tests.\n* Meta:\n  * Update dependencies.\n  * Improve code readability.\n  * Include version in min.js.\n\n### v2.0.6 (2018-11-06)\n\n* Trim trailing zeros in mask. Fixes [issue #18](https://github.com/Mottie/javascript-number-formatter/issues/18).\n\n### v2.0.0 \u0026ndash; 2.0.5 (2018-10-26)\n\n* Add `ignoreSign` option (modified to `enforeceMaskSign`!).\n* Switch to XO, AVA \u0026 rollup.\n* Meta: Update dot files \u0026 remove bower support.\n* Code cleanup \u0026 convert to ES2015.\n  * Rename `ignoreSign` to `enforceMaskSign` (default `false`).\n  * Reduce code complexity.\n  * Export as node module.\n  * Update TS with options.\n  * Switch demo to use lib file \u0026 highlight valid results.\n* Switch from Grunt to rollup.\n* Switch from IIFE to UMD output.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMottie%2Fjavascript-number-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMottie%2Fjavascript-number-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMottie%2Fjavascript-number-formatter/lists"}