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

strings-utils

v4.0.0

Published

A great set of 60 functions for string manipulation.

Readme

@zakahacecosas/

string-utils

A great set of 60 functions for string capitalization, validation, and manipulation; among other uses. Works with NodeJS, Bun, Deno, and (if transpiled to JavaScript) with any web browser. Includes features for CLIs.

Installation

# deno
deno add jsr:@zakahacecosas/string-utils
# npm
npx jsr add @zakahacecosas/string-utils
# yarn
yarn add jsr:@zakahacecosas/string-utils
# pnpm
pnpm add jsr:@zakahacecosas/string-utils
# bun
bunx jsr add @zakahacecosas/string-utils

Feature highlights

String validation

import { type UnknownString, validate } from "@zakahacecosas/string-utils";
import { getInput } from "somewhere";

function greet(who: UnknownString) {
  if (!validate(who)) throw new Error("No name was specified!");
  console.log(`Hi, ${who}!`);
}

greet(null); // throws
greet("   "); // throws. if you did `if (!who) throw...` instead it'd log "Hi,    !"
greet("Dima"); // "Hi, Dima!"

string-utils offers a validate(str) function to ensure a string is valid. It handles undefined, null, and empty values (including spaces-only strings) without needing .trim(). It's also a type guard, so TS knows the string is safe to use after the call.

We also expose an UnknownString type ("" | string | undefined | null) for defining params that maybe are a valid string (recommended for user-input-based variables).

String normalization

import { normalize } from "@zakahacecosas/string-utils";

const query = "   mY  sEaRcH      qUÉry_1  ";

const str = normalize(query);
const str2 = normalize(query, { strict: true });
console.log(str); // "my search query_1"
console.log(str2); // "mysearchquery1"

string-utils offers a validate(str, options) function to normalize strings, so they're easier to work with. It removes outer and inner trailing spaces, lowercases everything, and replaces weird characters like á or ë with a and e. When strict is set to true, it also removes underscores, hyphens, and other non-alphanumeric characters.

String capitalization

import { toKebabCase, toLowerCaseFirst, toPascalCase, toUpperCaseFirst } from "@zakahacecosas/string-utils";

// for reading
console.log(toUpperCaseFirst("javaScript")); // JavaScript
console.log(toLowerCaseFirst("JavaScript")); // javaScript

// for coding
console.log(toPascalCase("this is a variable")); // ThisIsAVariable
console.log(toKebabCase("this is a variable")); // this-is-a-variable

string-utils offers various capitalization methods like toUpperCaseFirst(str), toLowerCaseFirst(str), capitalizeWords(str), or toTitleCase(str). It also includes code capitalization methods like toCamelCase(str), toSnakeCase(str), and so on.

CLI formatting

import { table } from "@zakahacecosas/string-utils";

console.log(table(
  [
    {
      Key: "Value",
      Key2: "Value 2",
    },
    {
      Key: "I'm a table!",
      Key2: "Value 3",
    },
  ],
));
/* output:
┌───────────────┬──────────┐
│ Key           │ Key2     │
├───────────────┼──────────┤
│ Value         │ Value 2  │
│ I'm a table!  │ Value 3  │
└───────────────┴──────────┘
*/

We also provide a .table() method, similar to console.table(). The difference is that we don't add the annoying (idx) column AND we don't give the JavaScript formatting to the table's contents; in other words:

import { table } from "@zakahacecosas/string-utils";

console.log(table(
  [
    {
      Key: "\x1b[31mValue\x1b[0m",
    },
  ],
));
/* output would look like this and "Value" would be red:
┌────────┐
│ Key    │
├────────┤
│ Value  │
└────────┘
*/

console.table({
  Key: "\x1b[31mValue\x1b[0m",
});
/* output would be like this:
┌───────┬────────────────────────┐
│ (idx) │ Values                 │
├───────┼────────────────────────┤
│ Key   │ "\x1b[31mValue\x1b[0m" │
└───────┴────────────────────────┘
*/

It's basically console.table() the way it should be.

There's a lot more

We're currently serving 60 different functions, and that'd be a lot to write in here. You've got general utilities like truncate(str), mask(str, options), pluralOrNot(str, number) or normalizeArray(str), splitting utilities like kominator(str, separator) or splitKebabCase(str), as well as reveal(str) and testFlag(str, target) for CLIs, slugify(str) for URLs, and the list goes on.

Documentation

The module is fully documented in jsr.io, click here for module documentation.

All functions have rich JSDoc (examples included) anyway, so your editor itself works as your documentation.