# strip-indent

> Strip leading whitespace from each line in a string

Latest version **4.1.1** (published 2025-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install strip-indent
pnpm add strip-indent
yarn add strip-indent
bun add strip-indent
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2025-10-12 |
| First published | 2014-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 150 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | strip, indent, indentation, normalize, remove, delete, whitespace, space, tab, string, dedent |

## Links

- npm: https://www.npmjs.com/package/strip-indent
- Repository: https://github.com/sindresorhus/strip-indent
- Homepage: https://github.com/sindresorhus/strip-indent#readme
- Issues: https://github.com/sindresorhus/strip-indent/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/strip-indent

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 4.1.1 (latest) — 2025-10-12
- 4.1.0 — 2025-09-11
- 4.0.0 — 2021-05-03
- 3.0.0 — 2019-04-17
- 2.0.0 — 2016-04-22
- 1.0.1 — 2015-02-16
- 1.0.0 — 2014-08-13
- 0.1.3 — 2014-04-29
- 0.1.2 — 2014-04-16
- 0.1.1 — 2014-04-06
- 0.1.0 — 2014-03-29

## README

# strip-indent

> Strip leading whitespace from each line in a string

The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.

Useful for removing redundant indentation.

## Install

```sh
npm install strip-indent
```

## Usage

```js
import stripIndent from 'strip-indent';

const string = '\tunicorn\n\t\tcake';
/*
	unicorn
		cake
*/

stripIndent(string);
/*
unicorn
	cake
*/
```

## API

### stripIndent(string)

Strip leading whitespace from each line in a string.

The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.

### dedent(string)

Strip leading whitespace from each line in a string and remove surrounding blank lines.

Like `stripIndent()`, but also removes leading and trailing lines that contain only whitespace. Useful for template literals and multi-line strings where you want clean boundaries.

```js
import {dedent} from 'strip-indent';

dedent(`
	unicorn
		cake
`);
/*
unicorn
	cake
*/
```

## Related

- [strip-indent-cli](https://github.com/sindresorhus/strip-indent-cli) - CLI for this module
- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
- [redent](https://github.com/sindresorhus/redent) - Strip redundant indentation and indent the string

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