Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string-remove-thousand-separators

codsen2.3kMIT7.0.19TypeScript support: included

Detects and removes thousand separators (dot/comma/quote/space) from string-type digits

amount, currency, digits, from, numbers, remove, separator, separators, string, thousand, thousands

readme

string-remove-thousand-separators

Detects and removes thousand separators (dot/comma/quote/space) from string-type digits

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 5.1.0 (npm i string-remove-thousand-separators@5.1.0).

npm i string-remove-thousand-separators

Quick Take

import { strict as assert } from "assert";

import { remSep } from "string-remove-thousand-separators";

// 🇬🇧 🇺🇸 thousand separators:
assert.equal(remSep("1,000,000.00"), "1000000.00");

// 🇷🇺  thousand separators:
assert.equal(remSep("1 000 000,00"), "1000000,00");
// (if you want it converted to Western notation with dot,
// set opts.forceUKStyle = true

// 🇨🇭 thousand separators:
assert.equal(remSep("1'000'000.00"), "1000000.00");

// IT'S SMART TOO:

// will not delete if the thousand separators are mixed:
const input = "100,000,000.000";
assert.equal(remSep(input), input);
// ^ does nothing

// but will remove empty space, even if there is no decimal separator:
// (that's to cope with Russian notation integers that use thousand separators)
assert.equal(remSep("100 000 000 000"), "100000000000");

// while removing thousand separators, it will also pad the digits to two decimal places
// (optional, on by default, to turn it off set opts.padSingleDecimalPlaceNumbers to `false`):
assert.equal(remSep("100,000.2"), "100000.20");
console.log();
// ^ Western notation

assert.equal(remSep("100 000,2"), "100000,20");
// ^ Russian notation

assert.equal(remSep("100'000.2"), "100000.20");
// ^ Swiss notation

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

7.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

6.2.0 (2022-08-12)

Features

6.1.3 (2022-04-18)

Fixed

6.1.0 (2022-04-10)

Features

6.0.13 (2022-03-21)

Fixed

  • exit early if number less than one is given (dc4ffc1), closes #42

6.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

5.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

5.0.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

5.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

5.0.0 (2021-01-23)

Features

  • rewrite in TS, start using named exports (caa3f29)

BREAKING CHANGES

  • previously: import remSep from ... - now import { remSep } from ...

4.0.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

2.6.0 (2019-01-20)

  • Various documentation and setup tweaks after we migrated to monorepo
  • Setup refresh: updated dependencies and all config files using automated tools

2.4.0 (2018-10-26)

  • Updated all dependencies
  • Restored coveralls.io reporting
  • Restored unit test linting

2.3.0 (2018-06-20)

2.2.0 (2018-06-16)

GitHub sold us out. In the meantime, we:

  • Migrated to BitBucket (to host repo + perform CI) and Codacy (for code quality audit)
  • Dropped BitHound (RIP) and Travis

2.1.0 (2018-05-26)

  • Set up Prettier on a custom ESLint rule set.
  • Removed package.lock and .editorconfig
  • Wired Rollup to remove comments from non-dev builds. This means we can now leave the console.logs in the source code — there's no need to comment-out console.log statements or care about them not spilling into production. Now it's done automatically.
  • Unit tests are pointing at ES modules build, which means that code coverage is correct now, without Babel functions being missed. This is important because now code coverage is real again and now there are no excuses not to perfect it.

2.0.0 (2017-11-08)

  • Rewrote in ES Modules and set up Rollup to serve 3 flavours: 1. CommonJS, 2. UMD and 3. ES Modules.

1.2.0 (2017-09-22)

  • Dropped JS Standard and switched to raw ESLint on airbnb-base preset with override to ban semicolons.

1.1.0 (2017-08-16)

  • New opts.removeThousandSeparatorsFromNumbers controls the removal of thousand separators. That's in case somebody would want only to pad the digits (opts.padSingleDecimalPlaceNumbers) and/or force the decimal notation (opts.forceUKStyle)

1.0.0 (2017-08-15)

  • First public release