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

escape-html

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escape-html

Escape string for use in HTML

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28M
decreased by-8.97%
Maintainers
2
Weekly downloads
 
Created

What is escape-html?

The escape-html package is designed to provide a simple and efficient way to escape HTML entities in strings. This is particularly useful to prevent XSS (Cross-Site Scripting) attacks by sanitizing user input or any data that might be dynamically inserted into HTML documents. The primary functionality of this package is to convert characters like '<', '>', '&', '"', and "'" into their corresponding HTML entities, making the output safe to include in HTML content.

What are escape-html's main functionalities?

Escaping HTML entities

This feature allows the conversion of potentially dangerous characters into their safe HTML entity equivalents. The provided code sample demonstrates how to use the escape-html package to escape a string that contains HTML and JavaScript, which could be harmful if rendered directly in a web page.

"const escapeHtml = require('escape-html');\nconst unsafeString = '<script>alert(\"XSS\")</script>';\nconst safeString = escapeHtml(unsafeString);\nconsole.log(safeString); // Output: &lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;"

Other packages similar to escape-html

Keywords

FAQs

Package last updated on 01 Sep 2015

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