# shellwords

> Manipulate strings according to the word parsing rules of the UNIX Bourne shell.

Latest version **1.1.1** (published 2025-07-11) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2025-07-11 |
| First published | 2011-11-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Jimmy Cuadra |
| Maintainers | jimmycuadra |
| Keywords | shellwords, shell, unix, bourne, bash, command line, ruby, stdlib |

## Links

- npm: https://www.npmjs.com/package/shellwords
- Repository: https://github.com/jimmycuadra/shellwords
- Issues: https://github.com/jimmycuadra/shellwords/issues
- npm.io page: https://npm.io/package/shellwords

## Recent versions

- 1.1.1 (latest) — 2025-07-11
- 1.1.0 — 2025-06-28
- 1.0.1 — 2022-02-01
- 1.0.0 — 2022-02-01
- 0.1.1 — 2017-08-17
- 0.1.0 — 2012-07-21
- 0.0.2 — 2012-06-28
- 0.0.1 — 2011-11-13

## README

# Shellwords

Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on [the Ruby module of the same name](https://docs.ruby-lang.org/en/3.1/Shellwords.html).

## Installation

With npm:

```
npm install shellwords
```

With pnpm:

```
pnpm add shellwords
```

With Yarn:

```
yarn add shellwords
```

## API

Shellwords exports the following functions, shown here in the TypeScript declaration file format.

``` typescript
/**
 * Splits a string into an array of tokens in the same way the UNIX Bourne shell does.
 *
 * @param line A string to split.
 * @returns An array of the split tokens.
 */
export declare const split: (line?: string) => string[];

/**
 * Escapes a string so that it can be safely used in a Bourne shell command line.
 *
 * @param str A string to escape.
 * @returns The escaped string.
 */
export declare const escape: (str?: string) => string;

/**
 * Builds a command line string from an argument list.
 *
 * @param array An array of string arguments.
 * @returns The command line string.
 */
export const join = (array: string[]) => string;
```

## Example

``` typescript
import { escape, split, join } from "shellwords";

split("foo 'bar baz'");
// ["foo", "bar baz"]

escape("What's up, yo?");
// 'What\\\'s\\ up,\\ yo\\?'

join(["What's", "up,", "gang?");
// 'What\\\'s up, gang\\?'
```

## Legal

shellwords is released under the MIT license. See `LICENSE`.

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