
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
Check if a string has ANSI escape codes
npm install has-ansi
import hasAnsi from 'has-ansi';
hasAnsi('\u001B[4mUnicorn\u001B[0m');
//=> true
hasAnsi('cake');
//=> false
Chalk is a popular npm package for styling terminal text. Unlike has-ansi, which is used to detect ANSI codes, Chalk is used to apply styles such as color, background color, and text formatting (bold, italic) through chainable methods. Chalk focuses on creating styled text, while has-ansi is about detection.
Strip-ansi is a package that removes ANSI escape codes from a string. It complements has-ansi by providing the functionality to clean a string of any ANSI codes that has-ansi can detect. While has-ansi checks for the presence of ANSI codes, strip-ansi is used to remove them.
Ansi-regex is a package that provides a regular expression to match ANSI escape codes. It can be used for a similar purpose as has-ansi, but with a more manual approach, giving developers the flexibility to use the regex in various contexts. Has-ansi offers a simpler and more direct API for detection.
FAQs
Check if a string has ANSI escape codes
The npm package has-ansi receives a total of 10,896,291 weekly downloads. As such, has-ansi popularity was classified as popular.
We found that has-ansi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.