{"id":22514655,"url":"https://github.com/cityssm/string-to-numeric","last_synced_at":"2025-08-03T16:31:11.546Z","repository":{"id":244413359,"uuid":"815163732","full_name":"cityssm/string-to-numeric","owner":"cityssm","description":"Parses formatted numeric strings into numbers. Handles cases parseFloat() misses.","archived":false,"fork":false,"pushed_at":"2024-11-18T04:47:00.000Z","size":944,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-21T21:53:06.391Z","etag":null,"topics":["accounting","parsefloat","parseint"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@cityssm/string-to-numeric","language":"TypeScript","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/cityssm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T13:41:36.000Z","updated_at":"2024-09-25T14:47:57.000Z","dependencies_parsed_at":"2024-06-14T15:52:25.637Z","dependency_job_id":null,"html_url":"https://github.com/cityssm/string-to-numeric","commit_stats":null,"previous_names":["cityssm/string-to-numeric"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityssm%2Fstring-to-numeric","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityssm%2Fstring-to-numeric/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityssm%2Fstring-to-numeric/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityssm%2Fstring-to-numeric/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cityssm","download_url":"https://codeload.github.com/cityssm/string-to-numeric/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228553252,"owners_count":17935963,"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","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":["accounting","parsefloat","parseint"],"created_at":"2024-12-07T03:20:05.208Z","updated_at":"2025-08-03T16:31:11.515Z","avatar_url":"https://github.com/cityssm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# String to Numeric\n\n[![npm (scoped)](https://img.shields.io/npm/v/@cityssm/string-to-numeric)](https://www.npmjs.com/package/@cityssm/string-to-numeric)\n[![DeepSource](https://app.deepsource.com/gh/cityssm/string-to-numeric.svg/?label=active+issues\u0026show_trend=true\u0026token=rG6OhTeMrjbjhlPrScSXEKEL)](https://app.deepsource.com/gh/cityssm/string-to-numeric/)\n[![codecov](https://codecov.io/gh/cityssm/string-to-numeric/graph/badge.svg?token=UGLDLEM3AW)](https://codecov.io/gh/cityssm/string-to-numeric)\n[![Coverage Testing](https://github.com/cityssm/string-to-numeric/actions/workflows/coverage.yml/badge.svg)](https://github.com/cityssm/string-to-numeric/actions/workflows/coverage.yml)\n\n**Parses formatted numeric strings into numbers. Handles cases `parseFloat()` misses.**\n\nHelpful when importing formatted data.\n\n![Screenshot of CSV File](docs/banner.png)\n\nSupports formatted numeric strings that are not supported by Javascript's\n`parseInt()` and `parseFloat()` functions, including:\n\n| Formatting                                                              | Example          | `Number.parseFloat()` | String to Numeric |\n| ----------------------------------------------------------------------- | ---------------- | --------------------- | ----------------- |\n| Numbers with thousands separators                                       | `\"1,234.56\"`     | ❌ `1`                | ✔️ `1234.56`      |\n| Numbers with surrounding brackets\u003cbr /\u003e (common in accounting)          | `\"(6000)\"`       | ❌ `NaN`              | ✔️ `-6000`        |\n| Numbers with leading units                                              | `\"$54.32\"`       | ❌ `NaN`              | ✔️ `54.32`        |\n| Numbers using a comma decimal separator\u003cbr /\u003e (with optional parameter) | `\"1,23\"`         | ❌ `1`                | ✔️ `1.23`         |\n| Combinations of formatting                                              | `\"($65,432.10)\"` | ❌ `NaN`              | ✔️ `-65432.1`     |\n\n## Installation\n\n```sh\nnpm install @cityssm/string-to-numeric\n```\n\n## Usage\n\n```javascript\nimport stringToNumeric from '@cityssm/string-to-numeric'\n\nconsole.log(stringToNumeric('1,234.56'))\n// =\u003e 1234.56\n\nconsole.log(stringToNumeric('$54.32'))\n// =\u003e 54.32\n```\n\n## Note\n\nThe decimal separator will attempt to be detected based on the computer's settings.\nIf the computer's locale settings do not match the decimal separator in string being parsed,\nset the `decimalSeparator` option.\n\n```javascript\nconsole.log(stringToNumeric('1,23', { decimalSeparator: ',' }))\n// =\u003e 1.23\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcityssm%2Fstring-to-numeric","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcityssm%2Fstring-to-numeric","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcityssm%2Fstring-to-numeric/lists"}