# text-encoding-identifier-case

Rule `unicorn/text-encoding-identifier-case`. Enforce consistent case for text encoding identifiers.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 12M weekly downloads of presets that enable it
- Trend: +40.1% last quarter
- Rank: #817 by reach, #1013 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/text-encoding-identifier-case` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/text-encoding-identifier-case.md) |
| Oxlint | `unicorn/text-encoding-identifier-case` | no | safe | plugin `unicorn`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/text-encoding-identifier-case.html) |

## Code examples

### Incorrect: the rule reports this

```js
await fs.readFile(file, 'UTF-8');
```

```js
await fs.readFile(file, 'ASCII');
```

```js
const string = buffer.toString('utf-8');
```

### Correct: the rule accepts this

```js
await fs.readFile(file, 'utf8');
```

```js
await fs.readFile(file, 'ascii');
```

```js
const string = buffer.toString('utf8');
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/text-encoding-identifier-case": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/text-encoding-identifier-case": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/require-module-specifiers](https://lintradar.dev/rules/unicorn/require-module-specifiers.md): Require non-empty specifier list in import and export statements.
- [unicorn/catch-error-name](https://lintradar.dev/rules/unicorn/catch-error-name.md): Enforce a specific parameter name in catch clauses.
- [unicorn/require-module-attributes](https://lintradar.dev/rules/unicorn/require-module-attributes.md): Require non-empty module attributes for imports and exports
- [unicorn/no-array-reduce](https://lintradar.dev/rules/unicorn/no-array-reduce.md): Disallow `Array#reduce()` and `Array#reduceRight()`.
- [unicorn/require-array-join-separator](https://lintradar.dev/rules/unicorn/require-array-join-separator.md): Enforce using the separator argument with `Array#join()`.
- [unicorn/no-immediate-mutation](https://lintradar.dev/rules/unicorn/no-immediate-mutation.md): Disallow immediate mutation after assignment and initialization immediately after declaration.

---

Web page: https://lintradar.dev/rules/unicorn/text-encoding-identifier-case. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
