https://github.com/anshsinghsonkhia/strip-diacritics
A utility package to remove diacritics and normalize text across multiple languages.
https://github.com/anshsinghsonkhia/strip-diacritics
npm-package
Last synced: 6 months ago
JSON representation
A utility package to remove diacritics and normalize text across multiple languages.
- Host: GitHub
- URL: https://github.com/anshsinghsonkhia/strip-diacritics
- Owner: AnshSinghSonkhia
- License: apache-2.0
- Created: 2025-03-29T14:51:42.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-29T15:03:49.000Z (7 months ago)
- Last Synced: 2025-03-29T15:32:16.519Z (7 months ago)
- Topics: npm-package
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/strip-diacritics
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# strip-diacritics
Remove diacritics (accents, special characters, and marks) from text, making it easier to normalize, search, and process text across multiple languages.
[](https://www.npmjs.com/package/strip-diacritics) [](LICENSE)
# 📦 Installation
Install via npm
```sh
npm i strip-diacritics
```Install via yarn
```sh
yarn add strip-diacritics
```# 🚀 Usage
```js
const { removeDiacritics, hasDiacritics, replaceDiacritics, normalizeText, getSupportedCharacters } = require('strip-diacritics');console.log(removeDiacritics("Málaga, façade, naïve"));
// Output: "Malaga, facade, naive"console.log(hasDiacritics("niño"));
// Output: trueconsole.log(replaceDiacritics("über", { 'ü': 'ue' }));
// Output: "ueber"console.log(normalizeText("München ist schön", "de"));
// Output: "Muenchen ist schoen"console.log(normalizeText("¡Hola, cómo estás!", "es"));
// Output: "Hola, como estas"console.log(normalizeText("Crème brûlée", "fr"));
// Output: "Creme brulee"console.log(normalizeText("Zażółć gęślą jaźń", "pl"));
// Output: "Zazolc gesla jazn"console.log(getSupportedCharacters());
```# 📜 API Reference
| Function Name | Description |
|--------------------------|-----------------------------------------------------------------------------|
| `removeDiacritics(text)` | Removes diacritics from a given text. |
| `hasDiacritics(text)` | Checks if a string contains diacritic characters. Returns true or false. |
| `replaceDiacritics(text, replacementMap)` | Replaces specific diacritics with custom values (e.g., é → e, ü → ue). |
| `normalizeText(text, locale = 'en')` | Converts text into a standardized form based on language rules. |
| `getSupportedCharacters()` | Returns a list of all characters that are modified. |