npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

replace-special-characters

v2.0.1

Published

Remove accents and replace special Latin characters with plain equivalents

Readme

replace-special-characters

npm version npm total downloads npm monthly downloads CI Zero dependencies License: MIT Open Source

Remove accents and replace special Latin characters with plain ASCII equivalents.

const replaceSpecialCharacters = require('replace-special-characters')

replaceSpecialCharacters('Olá, JäváSçrîpt!')
//=> 'Ola, JavaScript!'
  • Zero runtime dependencies.
  • TypeScript declarations included.
  • Compatible with CommonJS and ES module imports.
  • Supports Node.js 12 and newer.
  • Handles accents, ligatures, decomposed characters, and mathematical Latin letters.
  • Preserves emoji and symbols without a configured replacement.

Install

npm install replace-special-characters
yarn add replace-special-characters
pnpm add replace-special-characters

Usage

CommonJS

const replaceSpecialCharacters = require('replace-special-characters')

replaceSpecialCharacters('São Paulo')
//=> 'Sao Paulo'

ES modules

import replaceSpecialCharacters from 'replace-special-characters'

replaceSpecialCharacters('Æther Œuvre')
//=> 'AEther OEuvre'

TypeScript

import replaceSpecialCharacters = require('replace-special-characters')

replaceSpecialCharacters('JäváSçrîpt')
//=> 'JavaScript'

When to use this package

Use this package when you need predictable replacements for accented and special Latin characters.

Good use cases:

  • Normalizing names before search.
  • Preparing strings for slugs.
  • Comparing user input without accents.
  • Cleaning optional text fields.
  • Replacing Latin diacritics and ligatures.

Choose a full transliteration library instead when you need:

  • Transliteration for every language or writing system.
  • Locale-aware normalization.
  • Removal of emoji or arbitrary symbols.

API

replaceSpecialCharacters(value)

Returns a string with known accented and special Latin characters replaced by their ASCII equivalents.

value

Type: string | null | undefined

The text to normalize. null, undefined, and empty strings are returned unchanged.

Behavior

| Input | Output | | --- | --- | | 'JäváSçrîpt' | 'JavaScript' | | 'Olá' | 'Ola' | | 'Cafe\u0301' | 'Cafe' | | 'Æther Œuvre' | 'AEther OEuvre' | | 'Þing Ŋŋ ĸ' | 'THing Nn k' | | '𝕽' | 'R' | | 'JavaScript 🚀' | 'JavaScript 🚀' | | '' | '' | | null | null | | undefined | undefined |

Common recipes

Normalize before search

const normalizedQuery = replaceSpecialCharacters(userInput).toLowerCase()

Create a basic slug

const slug = replaceSpecialCharacters(title)
  .toLowerCase()
  .replace(/[^a-z0-9]+/g, '-')
  .replace(/^-|-$/g, '')

Why not only String.prototype.normalize?

String.prototype.normalize('NFD') decomposes many accented characters so their combining marks can be removed in a separate step. It does not cover every special Latin character handled by this package, such as ligatures and custom mappings like Æ to AE and Œ to OE.

This package combines selective Unicode normalization with an explicit character map. Unsupported characters remain unchanged instead of being removed.

Compatibility

The published package supports Node.js 12 and newer and has no runtime dependencies. Development requires Node.js 22.12 or newer.

Compatibility with end-of-life Node.js releases is maintained for existing applications, but an actively supported Node.js LTS release is recommended for security.

Recognized Latin characters followed by common combining marks are normalized before replacement when the runtime supports String.prototype.normalize.

Mathematical Latin letters represented by supplementary Unicode code points are converted to their ASCII equivalents. Mathematical Greek letters, digits, and other supplementary symbols remain unchanged.

For backward compatibility:

  • German sharp S keeps its historical single-character mapping: ß becomes s and becomes S.
  • Falsy non-string values previously accepted at runtime (false, 0, and NaN) are returned unchanged, but remain outside the TypeScript API.

Other non-string values throw a descriptive TypeError.

Contributing

Local development requires Node.js 22.12 or newer.

npm ci
npm run check

Fork the repository, create a branch, make your changes, and open a pull request. Include tests for behavior changes and use a Conventional Commit title.

See CONTRIBUTING.md for commit conventions and CHANGELOG.md for release notes.

License

MIT. See LICENSE.