---
url: /docs/guide/usage/linter/rules/unicorn/numeric-separators-style.md
---

### What it does

Enforces a convention of grouping digits using numeric separators.

### Why is this bad?

A long series of digits can be difficult to read, and
it can be difficult to determine the value of the number at a glance.
Breaking up the digits with numeric separators (`_`) can greatly
improve readability.

Compare the following two numbers and how easy it is to understand their magnitude:

```js
1000000000;
1_000_000_000;
```

This rule also enforces proper group size, for example
enforcing that the `_` separator is used every 3 digits.

### Examples

Examples of **incorrect** code for this rule:

```javascript
const invalid = [1_23_4444, 1_234.56789, 0xab_c_d_ef, 0b10_00_1111, 0o1_0_44_21, 1_294_28771_2n];
```

Examples of **correct** code for this rule:

```javascript
const valid = [1_234_567, 1_234.567_89, 0xab_cd_ef, 0b1000_1111, 0o10_4421, 1_294_287_712n];
```

## Configuration

This rule accepts a configuration object with the following properties:

### binary

type: `object`

default: `{"groupLength":4, "minimumDigits":0}`

Configuration for binary literals (e.g. `0b1010_0001` and bigint variants).
Controls how digits are grouped and when separators are applied.

#### binary.groupLength

type: `integer`

default: `4`

The number of digits per group when inserting numeric separators.
For example, a `groupLength` of 3 formats `1234567` as `1_234_567`.

#### binary.minimumDigits

type: `integer`

default: `0`

The minimum number of digits required before grouping is applied.
Values with fewer digits than this threshold will not be grouped.

#### binary.onlyIfContainsSeparator

type: `boolean`

Only enforce the rule when the numeric literal already contains a separator (`_`).

When `true`, numbers without separators are left as-is; when `false` (default),
grouping will be enforced for eligible numbers even if they don't include separators yet.

### hexadecimal

type: `object`

default: `{"groupLength":2, "minimumDigits":0}`

Configuration for hexadecimal literals (e.g. `0xAB_CD`, `0Xab_cd`, and bigint variants).
Controls how digits are grouped and when separators are applied.

#### hexadecimal.groupLength

type: `integer`

default: `2`

The number of digits per group when inserting numeric separators.
For example, a `groupLength` of 3 formats `1234567` as `1_234_567`.

#### hexadecimal.minimumDigits

type: `integer`

default: `0`

The minimum number of digits required before grouping is applied.
Values with fewer digits than this threshold will not be grouped.

#### hexadecimal.onlyIfContainsSeparator

type: `boolean`

Only enforce the rule when the numeric literal already contains a separator (`_`).

When `true`, numbers without separators are left as-is; when `false` (default),
grouping will be enforced for eligible numbers even if they don't include separators yet.

### number

type: `object`

Configuration for decimal numbers (integers, fraction parts, and exponents).
Controls how digits are grouped and when separators are applied.

#### number.fractionGroupLength

type: `integer`

default: `Infinity`

The size a group of digits in the fractional part (after the decimal point) should be.

#### number.groupLength

type: `integer`

default: `3`

The number of digits per group when inserting numeric separators.
For example, a `groupLength` of 3 formats `1234567` as `1_234_567`.

#### number.minimumDigits

type: `integer`

default: `5`

The minimum number of digits required before grouping is applied.
Values with fewer digits than this threshold will not be grouped.

#### number.onlyIfContainsSeparator

type: `boolean`

Only enforce the rule when the numeric literal already contains a separator (`_`).

When `true`, numbers without separators are left as-is; when `false` (default),
grouping will be enforced for eligible numbers even if they don't include separators yet.

### octal

type: `object`

default: `{"groupLength":4, "minimumDigits":0}`

Configuration for octal literals (e.g. `0o1234_5670` and bigint variants).
Controls how digits are grouped and when separators are applied.

#### octal.groupLength

type: `integer`

default: `4`

The number of digits per group when inserting numeric separators.
For example, a `groupLength` of 3 formats `1234567` as `1_234_567`.

#### octal.minimumDigits

type: `integer`

default: `0`

The minimum number of digits required before grouping is applied.
Values with fewer digits than this threshold will not be grouped.

#### octal.onlyIfContainsSeparator

type: `boolean`

Only enforce the rule when the numeric literal already contains a separator (`_`).

When `true`, numbers without separators are left as-is; when `false` (default),
grouping will be enforced for eligible numbers even if they don't include separators yet.

### onlyIfContainsSeparator

type: `boolean`

default: `false`

Only enforce the rule when the numeric literal already contains a separator (`_`).

When `true`, numbers without separators are left as-is; when `false` (default),
grouping will be enforced for eligible numbers even if they don't include separators yet.

## How to use

## Version

This rule was added in v0.0.19.

## References
