New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

string-strip-html

Package Overview
Dependencies
Maintainers
0
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-strip-html

Strip HTML tags from strings. No parser, accepts mixed sources.

13.4.12
latest
Source
npm
Version published
Weekly downloads
180K
9.68%
Maintainers
0
Weekly downloads
 
Created

What is string-strip-html?

The string-strip-html npm package is used to remove HTML tags from strings. It is useful for sanitizing user input, cleaning up text for display, and ensuring that text data is free from HTML elements.

What are string-strip-html's main functionalities?

Basic HTML Stripping

This feature allows you to remove HTML tags from a string, leaving only the text content. The example demonstrates stripping HTML tags from a simple string.

const { stripHtml } = require('string-strip-html');
const result = stripHtml('<p>Hello <strong>World</strong>!</p>');
console.log(result.result); // 'Hello World!'

Handling Self-Closing Tags

This feature handles self-closing tags, ensuring that they are removed from the string. The example shows how an image tag is stripped from the input string.

const { stripHtml } = require('string-strip-html');
const result = stripHtml('<img src="image.jpg" alt="Image" />');
console.log(result.result); // ''

Removing Attributes

This feature removes HTML tags along with their attributes, leaving only the text content. The example demonstrates stripping an anchor tag with an href attribute.

const { stripHtml } = require('string-strip-html');
const result = stripHtml('<a href="https://example.com">Link</a>');
console.log(result.result); // 'Link'

Other packages similar to string-strip-html

Keywords

code

FAQs

Package last updated on 02 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts