The `string-strip-html` package, currently at version 13.5.3, is a robust utility designed to efficiently remove HTML tags from arbitrary string inputs. It is actively maintained as part of the Codsen monorepo, with updates released as needed for feature enhancements and bug fixes. A key differentiator is its "no parser" approach, meaning it does not attempt to fully parse or validate HTML. This design makes it exceptionally resilient and suitable for stripping tags from malformed, incomplete, or "mixed" HTML sources often found in user-generated content or messy data, where traditional DOM parsers might fail or be overkill. It provides granular control over which tags to strip and offers options to remove entire tag-content blocks (e.g., `<script>...</script>`). Since version 9.0.0, the library is distributed exclusively as an ECMAScript Module (ESM), aligning with modern JavaScript ecosystem standards and requiring `import` syntax.
npm install string-strip-htmlVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic HTML stripping, whitespace handling, stripping tag contents, and proper handling of angle brackets that are not HTML tags.
Update your project to use ES modules with `import` syntax, or explicitly install version 8.5.0 (`npm i string-strip-html@8.5.0`) for CommonJS compatibility.
If you require a full HTML parser for validation, manipulation, or complex error correction, consider libraries like `jsdom` or `cheerio` instead. This library is best for simple, robust tag removal.
Carefully select which tags to include in `stripTogetherWithTheirContents`. Use this option primarily for tags whose content is irrelevant after stripping (e.g., `<script>`, `<style>`, `<pre>`) rather than general layout tags.
If using Node.js, ensure your package is configured for ESM (e.g., `"type": "module"` in `package.json`) and use `import { stripHtml } from 'string-strip-html';`. Alternatively, downgrade to version 8.5.0 for CommonJS support: `npm install string-strip-html@8.5.0`.Change the import statement to use named import syntax: `import { stripHtml } from 'string-strip-html';`.No dependency data recorded yet.