Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→string-remove-thousand-separatorsnext

string-remove-thousand-separators7.2.1

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

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • API — REMSEP()
  • API — DEFAULTS
  • API — VERSION
  • Changelog

Installation

Quick Take

Examples

  • Pad a single decimal digit while removing thousand separators
  • Leave a single decimal place unpadded
  • Convert a comma decimal separator to a dot
  • Remove spaced thousand separators when no decimal separator is present
  • Keep thousand separators while still normalising the outer quotes
  • Leave a value unchanged when it contains non-numeric text
  • Preserve a number whose separators are ambiguous
  • Remove spaces used as thousand separators
  • Remove apostrophes used as thousand separators

API — remSep()

The main function remSep() is imported like this:

It’s a function which takes three input arguments:

Input argumentTypeObligatoryDescription
str
Type: String
Obligatory: yes
strStringyesInput to work upon.
opts
Type: Plain object
Obligatory: no
optsPlain objectnoOptional Options Object.

None of the input arguments will be mutated by this program, we have unit tests to prove that.

The Optional Options Object has the following shape:

KeyTypeDefaultDescription
removeThousandSeparatorsFromNumbers
Type: Boolean
Default: true
removeThousandSeparatorsFromNumbersBooleantrueShould remove thousand separators? 1,000,000 → 1000000? Or Swiss-style, 1'000'000 → 1000000? Or Russian-style, 1 000 000 → 1000000?
padSingleDecimalPlaceNumbers
Type: Boolean
Default: true
padSingleDecimalPlaceNumbersBooleantruePad one decimal place numbers with zero? 100.2 → 100.20?
forceUKStyle
Type: Boolean
Default: false
forceUKStyleBooleanfalseConvert the decimal separator commas into dots? 1,5 → 1.5?

Here are all defaults in one place for copying:

The function will return a string, the input with thousand separators removed.

API — defaults

You can import defaults:

It's a plain object:

The main function calculates the options to be used by merging the options you passed with these defaults.

API — version

You can import version:

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab