# strip-debug

> Strip console, alert, and debugger statements from JavaScript code

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

## Install

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

## 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 | 8.0.0 |
| Published | 2025-09-09 |
| First published | 2014-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 86 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | strip, remove, delete, clean, debug, debugger, console, log, logging, js, javascript, ast, babel-plugin |

## Links

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

## Dependencies (1)

- [@types/babel__core](https://npm.io/package/@types/babel__core.md) ^7.20.5

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 8.0.0 (latest) — 2025-09-09
- 7.0.0 — 2022-11-29
- 6.0.0 — 2021-06-04
- 5.0.0 — 2021-04-06
- 4.0.0 — 2018-11-13
- 3.0.0 — 2018-02-28
- 2.0.0 — 2017-09-23
- 1.1.1 — 2015-03-12
- 1.1.0 — 2015-02-28
- 1.0.1 — 2014-09-09
- 1.0.0 — 2014-07-26
- 0.3.0 — 2014-03-06
- 0.2.0 — 2014-02-22
- 0.1.0 — 2014-01-11

## README

# strip-debug

> Strip `console`, `alert`, and `debugger` statements from JavaScript code

Useful for making sure you didn't leave any logging in production code.

## Usage

```sh
npm install @babel/core strip-debug
```

## Usage

```js
import {transformSync} from '@babel/core';
import stripDebug from 'strip-debug';

transformSync('function foo(){console.log("foo");alert("foo");debugger;}', {
	plugins: [stripDebug]
}).code;
//=> 'function foo() { void 0;void 0; }'
```

To prevent any side-effects, `console.*`/`alert*` is replaced with `void 0` instead of being stripped.

If you shadow the `console` global with your own local variable, it will still be removed.

## Ignoring specific lines

You can ignore specific statements from being stripped by using special comments:

```js
// strip-debug-ignore-next
console.log('This will NOT be stripped');

console.log('This will be stripped'); // strip-debug-ignore
```

Both comment styles work:
- `// strip-debug-ignore-next` - Ignores the next line
- `// strip-debug-ignore` - Ignores the current line (inline comment)
- `/* strip-debug-ignore-next */` - Block comment style also works

## Related

- [strip-debug-cli](https://github.com/sindresorhus/strip-debug-cli) - API for this package

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