{"library":"string-strip-html","title":"Strip HTML Tags from Strings","type":"library","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install string-strip-html"],"cli":null},"imports":["import { stripHtml } from 'string-strip-html';","import { stripHtml } from 'string-strip-html';","import type { StripHtmlOptions } from 'string-strip-html';"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://codsen.com/os/string-strip-html","github":"https://github.com/codsen/codsen","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/string-strip-html","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { strict as assert } from \"assert\";\nimport { stripHtml } from \"string-strip-html\";\n\n// Basic usage: removes HTML tags, replacing them with a single space.\nassert.equal(\n  stripHtml(\"Some text <b>and</b> text.\").result,\n  \"Some text and text.\"\n);\n\n// Handles consecutive tags gracefully by collapsing whitespace.\nassert.equal(stripHtml(\"aaa<div>bbb</div>ccc\").result, \"aaa bbb ccc\");\n\n// Option to strip specific tags along with their entire contents.\nassert.equal(\n  stripHtml(\"a <pre><code>void a;</code></pre> b\", {\n    stripTogetherWithTheirContents: [\n      \"script\", // default\n      \"style\",  // default\n      \"xml\",    // default\n      \"pre\"     // custom-added\n    ]\n  }).result,\n  \"a b\"\n);\n\n// Intelligently distinguishes between HTML tags and legitimate angle brackets.\nassert.equal(stripHtml(\"a < b and c > d\").result, \"a < b and c > d\");\n","lang":"javascript","description":"Demonstrates basic HTML stripping, whitespace handling, stripping tag contents, and proper handling of angle brackets that are not HTML tags.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}