# shescape

> simple shell escape library

Latest version **3.0.2** (published 2026-08-01) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install shescape
pnpm add shescape
yarn add shescape
bun add shescape
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-08-01 |
| First published | 2020-11-06 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^22.22.2 \|\| ^24.15.0 \|\| ^26 |
| Dependencies | 1 |
| Unpacked size | 163.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 9 |
| Author | Eric Cornelissen |
| Maintainers | ericcornelissen |
| Keywords | shell, escape, injection |

## Links

- npm: https://www.npmjs.com/package/shescape
- Repository: https://github.com/ericcornelissen/shescape
- Homepage: https://github.com/ericcornelissen/shescape#readme
- Issues: https://github.com/ericcornelissen/shescape/issues
- npm.io page: https://npm.io/package/shescape

## Dependencies (1)

- [which](https://npm.io/package/which.md) ^7.0.0

## Recent versions

- 3.0.2 (latest) — 2026-08-01
- 2.0.0-rc3 (next) — 2023-08-22
- 2.1.15 — 2026-08-01
- 3.0.1 — 2026-07-22
- 2.1.14 — 2026-07-22
- 3.0.0 — 2026-06-13
- 2.1.13 — 2026-06-13
- 2.1.12 — 2026-05-06
- 2.1.11 — 2026-04-07
- 2.1.10 — 2026-03-10
- 2.1.9 — 2026-03-06
- 2.1.8 — 2026-01-25
- 2.1.7 — 2025-11-22
- 2.1.6 — 2025-07-14
- 2.1.5 — 2025-06-19
- … 53 more at https://npm.io/package/shescape/versions

## README

<!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->

# Shescape

A simple shell escape library for JavaScript. Use it to escape user-controlled
inputs to shell commands to prevent [shell injection].

**Quick links**:
[npm][npm-url] |
[Source code] |
[License] |
[Changelog] |
[Security]

[changelog]: ./CHANGELOG.md
[license]: ./LICENSE
[npm-url]: https://www.npmjs.com/package/shescape
[shell injection]: ./docs/vocabulary.md#shell-injection
[security]: ./SECURITY.md
[source code]: https://github.com/ericcornelissen/shescape

## Features

- Lightweight
- Advanced shell detection
- Supports MacOS, Linux, and Windows
- Prevents environment variable access
- Protects against flag injection

### Shells

The following shells are officially supported and extensively tested. It is
recommended to only use shells found in this list.

- **Unix**: [Bash], [BusyBox], [csh], [Dash], [Zsh]
- **Windows**: [cmd.exe], [PowerShell]

If you want to use Shescape with another shell you can request it on GitHub by
opening [an issue].

[an issue]: https://github.com/ericcornelissen/shescape/issues
[bash]: https://en.wikipedia.org/wiki/Bash_(Unix_shell) "Bourne-Again Shell"
[busybox]: https://en.wikipedia.org/wiki/BusyBox "BusyBox"
[cmd.exe]: https://en.wikipedia.org/wiki/Cmd.exe "CMD.exe"
[csh]: https://en.wikipedia.org/wiki/C_shell "C shell"
[dash]: https://en.wikipedia.org/wiki/Almquist_shell#Dash "Debian Almquist Shell"
[powershell]: https://en.wikipedia.org/wiki/PowerShell "PowerShell"
[zsh]: https://en.wikipedia.org/wiki/Z_shell "Z shell"

## Usage

### Setup

1. Install `shescape`:

   ```shell
   npm install shescape
   ```

2. Import `shescape`:

   ```javascript
   import { Shescape } from "shescape";
   ```

3. Initialize `Shescape`.

   ```javascript
   const shescape = new Shescape(/* Options */);
   ```

4. Use `shescape`.

### Getting Started

- Look at the [use cases] for Shescape.
- Check the [recipes] for examples of how to use Shescape.
- Read the [tips] for additional ways to protect against shell injection.
- Having trouble? See the [troubleshooting] document for help.

[troubleshooting]: docs/troubleshoot.md
[recipes]: docs/recipes.md
[tips]: docs/tips.md
[use cases]: docs/use-cases.md

### Migrating from v2

View the [migration guidelines] for help.

[migration guidelines]: docs/migration.md

### API

View the [API] documentation of Shescape.

[api]: docs/api.md

### Testing

View the [testing] documentation for how to test code that uses Shescape.

[testing]: docs/testing.md

## License

The source code is licensed under the `MPL-2.0` license, see [LICENSE] for
the full license text. The documentation text is licensed under [CC BY-SA 4.0];
code snippets under the [MIT-0] license.

Supporting code (scripts and tests) is generally licensed under the `MIT` or
`MIT-0` license. Individual files may be licensed differently depending on the
intent or origin.

The license under which a given file is available can always be found in the
file's banner comment.

[cc by-sa 4.0]: ./docs/LICENSE-CC-BY-SA-4.0
[mit-0]: ./docs/LICENSE-MIT-0

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