Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

string-strip-html

Package Overview
Dependencies
Maintainers
1
Versions
225
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.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
218K
decreased by-4.25%
Maintainers
1
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

FAQs

Package last updated on 04 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc