# string.prototype.replaceall

> Spec-compliant polyfill for String.prototype.replaceAll ESnext proposal

Latest version **1.0.11** (published 2025-09-12) · MIT license · 0 weekly downloads

> **Native alternative:** String.prototype.replaceAll — Use native JavaScript (Node 15.0.0+) (https://developer.mozilla.orgGlobal_Objects/String/replaceAll)

## Install

```sh
npm install string.prototype.replaceall
pnpm add string.prototype.replaceall
yarn add string.prototype.replaceall
bun add string.prototype.replaceall
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2025-09-12 |
| First published | 2019-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 8 |
| Unpacked size | 28.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | string, replaceall, replace, regex, all, es2020, esnext, javascript, spec |

## Links

- npm: https://www.npmjs.com/package/string.prototype.replaceall
- Repository: https://github.com/es-shims/String.prototype.replaceAll
- Homepage: https://github.com/es-shims/String.prototype.replaceAll#readme
- Issues: https://github.com/es-shims/String.prototype.replaceAll/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/string.prototype.replaceall

## Dependencies (8)

- [is-regex](https://npm.io/package/is-regex.md) ^1.2.1
- [call-bind](https://npm.io/package/call-bind.md) ^1.0.8
- [es-errors](https://npm.io/package/es-errors.md) ^1.3.0
- [es-abstract](https://npm.io/package/es-abstract.md) ^1.24.0
- [has-symbols](https://npm.io/package/has-symbols.md) ^1.1.0
- [get-intrinsic](https://npm.io/package/get-intrinsic.md) ^1.3.0
- [es-object-atoms](https://npm.io/package/es-object-atoms.md) ^1.1.1
- [define-properties](https://npm.io/package/define-properties.md) ^1.2.1

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.11 (latest) — 2025-09-12
- 1.0.10 — 2024-03-20
- 1.0.9 — 2024-02-05
- 1.0.8 — 2023-09-03
- 1.0.7 — 2022-11-07
- 1.0.6 — 2021-10-05
- 1.0.5 — 2021-02-22
- 1.0.4 — 2020-11-21
- 1.0.3 — 2019-12-14
- 1.0.2 — 2019-10-31
- 1.0.1 — 2019-10-26
- 1.0.0 — 2019-09-04

## README

# string.prototype.replaceall <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

ES Proposal spec-compliant shim for String.prototype.replaceAll. Invoke its "shim" method to shim `String.prototype.replaceAll` if it is unavailable or noncompliant.

This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment, and complies with the [proposed spec](https://github.com/tc39/proposal-string-replaceall).

Most common usage:
```js
const assert = require('assert');
const replaceAll = require('string.prototype.replaceall');

const str = 'aabc';

// replaceAll and replace are the same, when given a global regex to replace
assert.equal(replaceAll(str, /a/g, 'z'), str.replace(/a/g, 'z'));

// replace, with a string, replaces once
assert.equal(str.replace('a', 'z'), 'zabc');

// replaceAll, with a string, replaces all
assert.equal(replaceAll(str, 'a', 'z'), 'zzbc');

replaceAll.shim(); // will be a no-op if not needed

// replaceAll and replace are the same, when given a global regex to replace
assert.equal(str.replaceAll(/a/g, 'z'), str.replace(/a/g, 'z'));

// replace, with a string, replaces once
assert.equal(str.replace('a', 'z'), 'zabc');

// replaceAll, with a string, replaces all
assert.equal(str.replaceAll('a', 'z'), 'zzbc');
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[package-url]: https://npmjs.com/package/string.prototype.replaceall
[npm-version-svg]: https://versionbadg.es/es-shims/String.prototype.replaceAll.svg
[deps-svg]: https://david-dm.org/es-shims/String.prototype.replaceAll.svg
[deps-url]: https://david-dm.org/es-shims/String.prototype.replaceAll
[dev-deps-svg]: https://david-dm.org/es-shims/String.prototype.replaceAll/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/String.prototype.replaceAll#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/string.prototype.replaceall.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/string.prototype.replaceall.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/string.prototype.replaceall.svg
[downloads-url]: https://npm-stat.com/charts.html?package=string.prototype.replaceall
[codecov-image]: https://codecov.io/gh/es-shims/string.prototype.replaceall/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/string.prototype.replaceall/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/string.prototype.replaceall
[actions-url]: https://github.com/es-shims/string.prototype.replacealstring.prototype.replaceall

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