# isotropic-character-fold

> Replace accented and special characters with their ASCII equivalents

Latest version **0.9.1** (published 2026-08-24) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install isotropic-character-fold
pnpm add isotropic-character-fold
yarn add isotropic-character-fold
bun add isotropic-character-fold
```

## Health

**Score 50/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2026-08-24 |
| First published | 2017-09-12 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | ^26.7.0 |
| Dependencies | 1 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Steven Olmsted |
| Maintainers | ibigroup |
| Keywords | accents, ascii, diacritics, fold, isotropic, normalize, transliterate, unicode |

## Links

- npm: https://www.npmjs.com/package/isotropic-character-fold
- Repository: https://github.com/ibi-group/isotropic-character-fold
- Issues: https://github.com/ibi-group/isotropic-character-fold/issues
- npm.io page: https://npm.io/package/isotropic-character-fold

## Dependencies (1)

- [diacritics-map](https://npm.io/package/diacritics-map.md) ~0.1.0

## Recent versions

- 0.9.1 (latest) — 2026-08-24
- 0.9.0 — 2026-07-16
- 0.8.1 — 2025-04-10
- 0.8.0 — 2024-07-30
- 0.7.0 — 2021-02-22
- 0.6.0 — 2020-07-27
- 0.5.0 — 2019-05-10
- 0.4.2 — 2019-05-09
- 0.4.1 — 2019-05-09
- 0.4.0 — 2019-05-08
- 0.3.0 — 2019-02-18
- 0.2.0 — 2018-11-26
- 0.1.0 — 2017-09-12

## README

# isotropic-character-fold

[![npm version](https://img.shields.io/npm/v/isotropic-character-fold.svg)](https://www.npmjs.com/package/isotropic-character-fold)
[![License](https://img.shields.io/npm/l/isotropic-character-fold.svg)](https://github.com/ibi-group/isotropic-character-fold/blob/main/LICENSE)
![](https://img.shields.io/badge/tests-passing-brightgreen.svg)
![](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)

A lightweight utility to normalize strings by replacing special characters with their basic ASCII equivalents.

## Why Use This?

- **Improved Search Functionality**: Users often search without special characters, diacritics, or accents
- **Simplified String Comparison**: Makes it easier to compare strings regardless of special characters
- **Normalized Sorting**: Ensures consistent alphabetical sorting by treating similar characters the same

## Installation

```bash
npm install isotropic-character-fold
```

## Usage

```javascript
import _characterFold from 'isotropic-character-fold';

// Replace accented characters
_characterFold('résumé'); // returns "resume"

// Replace special character variants
_characterFold('ŧęṧᵵṨⓣȑïȵɠ'); // returns "testString"

// Handle combining characters
_characterFold('n̂őŕm̃àłȋẑĕ'); // returns "normalize"
```

## How It Works

`isotropic-character-fold` uses JavaScript's native `String.normalize('NFKC')` method combined with the `diacritics-map` package to:

1. Normalize Unicode characters to their canonical form
2. Replace diacritics and special characters with basic ASCII equivalents
3. Remove remaining non-spacing marks

The module handles a wide range of special characters including:
- Accented characters (é, ü, ñ, etc.)
- Special character variants (ⓣ, ṧ, etc.)
- Combining characters (characters with multiple diacritical marks)

## API

### characterFold(string)

Returns a normalized version of the input string with special characters replaced by their basic ASCII equivalents.

#### Parameters

- `string` (String): The string to normalize

#### Returns

- (String): The normalized string

## Examples

### Basic Character Replacement

```javascript
import _characterFold from 'isotropic-character-fold';

// Accented characters
_characterFold('café'); // returns "cafe"
_characterFold('naïve'); // returns "naive"

// Special letter variants
_characterFold('ⓈⓊⓃⓈⓗⒾⓃⒺ'); // returns "SUNSHINE"
```

### Use in Search Implementation

```javascript
import _characterFold from 'isotropic-character-fold';

const _searchItems = ({
    items,
    query
}) => {
    const normalizedQuery = _characterFold(query).toLowerCase();

    return items.filter(item => {
        const normalizedItem = _characterFold(item).toLowerCase();

        return normalizedItem.includes(normalizedQuery);
    });
}

// Example usage
_searchItems({
    items: [
        'Café Americano',
        'Cafè Latte',
        'Café Mocha'
    ],
    query: 'cafe'
}); // Returns all items

_searchItems({
    items: [
        'résumé',
        'Resume',
        'RÉSUMÉ'
    ],
    query: 'resume'
}); // Returns all items
```

### Use in Sorting

```javascript
import _characterFold from 'isotropic-character-fold';

const _names = [
        'Zoë',
        'Ángel',
        'Adrian',
        'Bob'
    ],
    // Sort with character folding
    _sortedNames = _names.toSorted((a, b) => _characterFold(a).localeCompare(_characterFold(b)));

// _sortedNames: ['Adrian', 'Ángel', 'Bob', 'Zoë']
```

## Contributing

Please refer to [CONTRIBUTING.md](https://github.com/ibi-group/isotropic-character-fold/blob/main/CONTRIBUTING.md) for contribution guidelines.

## Issues

If you encounter any issues, please file them at https://github.com/ibi-group/isotropic-character-fold/issues

---
_Source: https://npm.io/package/isotropic-character-fold · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
