normalize-diacritics
Remove accents/ diacritics in string
Simple NPM package to remove any accents/ diacritics found in a string.
Table of contents
Pre-requisite
- Node.js >= 10.18.1
- NPM >= 6.13.4 (NPM comes with Node.js so there is no need to install separately.)
Install
# Install via NPM
$ npm install --save normalize-diacritics
Usage
TypeScript or ES Modules
import { normalize } from 'normalize-diacritics';
/** Assuming top-level await is enabled... */
await normalize('söme stüff with áccènts'); // 'some stuff with accents'
Node.js
const { normalize } = require('normalize-diacritics');
/** Assuming top-level await is enabled... */
await normalize('söme stüff with áccènts'); // 'some stuff with accents'
Browser
ES Modules
<script type="module">
import { normalize } from 'https://unpkg.com/normalize-diacritics@latest/dist/normalize-diacritics.min.js';
// --snip
</script>
UMD
<script src="https://unpkg.com/normalize-diacritics@latest/dist/normalize-diacritics.umd.min.js"></script>
<script>
const { normalize } = window.NormalizeDiacritics;
// --snip
</script>
Demo
deno
API Reference
normalize([input])
input
<?string> Optional input string that contains accents/ diacritics.- returns: <Promise<string>> Promise which resolves with normalized input string.
This method normalizes any accents/ diacritics found in a given input string and output a normalized string as a result.
normalizeSync([input])
This methods works the same as normalize([input])
except that this is the synchronous version.
Contributing
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
License
MIT License © Rong Sen Ng