npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-string-similarity

v1.3.2

Published

A TypeScript library for string similarity comparison

Readme

Node String Similarity

A TypeScript library for comparing strings using various similarity algorithms.

Features

  • Levenshtein Distance: Measures the minimum number of edits required to transform one string into another.
  • Jaro-Winkler Distance: Gives more weight to matching characters at the start of the strings.
  • Cosine Similarity: Measures similarity based on vector representations of strings.
  • Dice's Coefficient: Measures overlap between two sets of bigrams.
  • Batch Comparison: Compare one string against a list of strings.
  • Threshold-Based Matching: Filter matches based on a similarity threshold.
  • Unicode Support: Handles multi-byte characters and non-English languages.
  • CLI Tool: Command-line interface for quick comparisons.
  • RESTful API: Expose string similarity functionalities as HTTP endpoints.
  • Database Integration: Utilities for finding similar entries in a database.
  • Visualization: Highlight differences between two strings.

Installation

npm install node-string-similarity

Usage

Importing the Library

import {
  compareStrings,
  jaroWinklerDistance,
  cosineSimilarity,
  diceCoefficient,
  batchCompareStrings,
  findMatchesAboveThreshold,
} from "node-string-similarity";

Comparing Strings

const similarity = compareStrings("hello", "hell");
console.log(`Similarity: ${similarity}`);

Using Jaro-Winkler Distance

const similarity = jaroWinklerDistance("hello", "hell");
console.log(`Jaro-Winkler Similarity: ${similarity}`);

Batch Comparison

const results = batchCompareStrings("hello", ["hi", "hey", "hello", "world"]);
console.log(results);

Threshold-Based Matching

const matches = findMatchesAboveThreshold("hello", ["hi", "hey", "hello", "world"], 0.8);
console.log(matches);

Visualization

import { visualizeStringDifferences } from "node-string-similarity/visualization";

const visualization = visualizeStringDifferences("hello", "hell");
console.log(visualization);

CLI Tool

Installation

npm install -g node-string-similarity

Usage

node-string-similarity compare "hello" "world"
node-string-similarity jaro-winkler "hello" "hell"
node-string-similarity cosine "hello" "world"
node-string-similarity dice "hello" "hell"

RESTful API

Starting the Server

node dist/api/server.js

Endpoints

  • POST /compare
  • POST /jaro-winkler
  • POST /cosine
  • POST /dice

Example Request

{
  "str1": "hello",
  "str2": "world"
}

Example Response

{
  "similarity": 0.4
}

Database Integration

Finding Similar Entries

import { findSimilarEntries } from "node-string-similarity/dbUtils";

const results = await findSimilarEntries("hello", "my_table", "my_column", 0.8);
console.log(results);

Inserting a String Entry

import { insertStringEntry } from "node-string-similarity/dbUtils";

await insertStringEntry("my_table", "my_column", "hello");

Testing

Run the tests using Jest:

npm test

Contributing

Contributions are welcome! Please submit a pull request or open an issue for any bugs or feature requests.

License

This project is licensed under the MIT License.