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

peasytext

v0.2.2

Published

Pure TypeScript text processing toolkit — 15 tools for case conversion, slug generation, word counting, line sorting, Base64/URL/HTML encoding, find & replace, deduplication, line numbering, pattern extraction, text diffing, Lorem Ipsum generation, JSON f

Downloads

474

Readme

peasytext

npm version TypeScript License: MIT Zero Dependencies GitHub stars

Pure TypeScript text processing toolkit — 15 tools for case conversion, slug generation, word counting, line sorting, Base64/URL/HTML encoding, find & replace, deduplication, line numbering, pattern extraction, text diffing, Lorem Ipsum generation, JSON formatting, and text reversal. Zero dependencies. Tree-shakeable ESM.

Extracted from the client-side engines at peasytext.com, where all 15 text tools run entirely in the browser. This package provides the same functionality for Node.js, Deno, Bun, and browser environments.

Try the interactive tools at peasytext.com — text case conversion, word counting, slug generation, Base64 encoding, JSON formatting, and 10 more tools

Table of Contents

Install

npm install peasytext

Quick Start

import { toCase, slugify, countText, extract } from "peasytext";

// Convert text between 13 case formats
console.log(toCase("hello world", "pascal"));     // "HelloWorld"
console.log(toCase("hello world", "snake"));      // "hello_world"
console.log(toCase("hello world", "constant"));   // "HELLO_WORLD"

// Generate URL-friendly slugs with diacritic handling
console.log(slugify("Crème brûlée recipe!"));     // "creme-brulee-recipe"

// Count words, sentences, reading time
const stats = countText("Hello world. How are you today?");
console.log(stats.words);        // 6
console.log(stats.sentences);    // 2
console.log(stats.readingTime);  // "< 1 min"

// Extract patterns from text
const emails = extract("Contact [email protected] or [email protected]", "emails");
console.log(emails);  // ["[email protected]", "[email protected]"]

What You Can Do

Case Conversion

Convert text between 13 case formats — from basic upper/lower to programming conventions like camelCase, snake_case, and CONSTANT_CASE. Automatically handles camelCase and snake_case input by splitting on word boundaries.

| Case | Example | Use Case | |------|---------|----------| | upper | HELLO WORLD | Constants, emphasis | | lower | hello world | Normalization | | title | Hello World | Headings, titles | | sentence | Hello world | Natural text | | camel | helloWorld | JavaScript variables | | pascal | HelloWorld | Class names | | snake | hello_world | Python variables | | kebab | hello-world | CSS classes, URLs | | constant | HELLO_WORLD | Constants, env vars | | dot | hello.world | Package names | | path | hello/world | File paths | | alternating | hElLo WoRlD | Sarcasm text | | inverse | hELLO wORLD | Inversion |

import { toCase } from "peasytext";

// Programming case conversions
console.log(toCase("user full name", "camel"));     // "userFullName"
console.log(toCase("user full name", "pascal"));    // "UserFullName"
console.log(toCase("user full name", "snake"));     // "user_full_name"
console.log(toCase("user full name", "constant"));  // "USER_FULL_NAME"

Learn more: Text Case Converter · Convert Case and Clean Text Guide · What is Case Conversion?

Slug Generation

Convert any text to a URL-friendly slug. Handles Unicode, diacritics, and special characters — essential for SEO-friendly URLs, file naming, and database keys.

import { slugify } from "peasytext";

// Diacritic stripping with NFD normalization
console.log(slugify("Crème Brûlée — The Recipe"));  // "creme-brulee-the-recipe"
console.log(slugify("München Straße"));               // "munchen-strasse"

// Custom separator and max length
console.log(slugify("Hello World", { separator: "_" }));             // "hello_world"
console.log(slugify("A very long title here", { maxLength: 10 }));   // "a-very"

Learn more: Slug Generator · Slug Generation and URL-Safe Strings · What is a Slug?

Text Statistics

Count characters, words, sentences, paragraphs, and lines. Estimates reading time based on configurable words-per-minute — useful for blog posts, content management, and SEO metadata.

import { countText } from "peasytext";

const stats = countText("Hello world. This is a test.\n\nNew paragraph here.");
console.log(stats.words);        // 9
console.log(stats.sentences);    // 3
console.log(stats.paragraphs);   // 2
console.log(stats.readingTime);  // "< 1 min"

Learn more: Text Counter · Word Character Line Counting Best Practices · What is Word Count?

Line Sorting

Sort lines alphabetically, by length, numerically, or reverse order. The shuffle mode uses Fisher-Yates for uniform random distribution.

import { sortLines } from "peasytext";

const text = "banana\napple\ncherry";
console.log(sortLines(text, "alpha"));        // apple\nbanana\ncherry
console.log(sortLines(text, "length"));       // apple\nbanana\ncherry
console.log(sortLines("10\n2\n30", "numeric"));  // 2\n10\n30

Learn more: Sort Lines Tool · How to Sort Text Lines · What is Line Ending?

Base64 Encoding

Encode and decode Base64 with full UTF-8 support — handles emoji, CJK characters, and all Unicode. Works in both browser (using btoa/atob + TextEncoder) and Node.js (using Buffer).

import { base64Encode, base64Decode } from "peasytext";

const encoded = base64Encode("Hello, 世界! 🌍");
console.log(encoded);                    // "SGVsbG8sIOS4lueVjCEg8J+MjQ=="
console.log(base64Decode(encoded));      // "Hello, 世界! 🌍"

Learn more: Base64 Encode Decode Tool · Base64 Encoding Guide · How to Encode Decode Base64

URL & HTML Encoding

import { urlEncode, urlDecode, htmlEncode, htmlDecode } from "peasytext";

// URL encoding with optional plus-for-spaces
console.log(urlEncode("hello world"));       // "hello%20world"
console.log(urlEncode("hello world", true)); // "hello+world"
console.log(urlDecode("hello%20world"));     // "hello world"

// HTML entity encoding — prevents XSS in user-generated content
console.log(htmlEncode('<script>alert("xss")</script>'));
// "&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;"

Learn more: URL Encode Decode Tool · HTML Entity Encoder · What is an Escape Character?

Find & Replace

Plain text and regex find & replace with case sensitivity options.

import { findReplace } from "peasytext";

// Case-insensitive replace
console.log(findReplace("Hello World", "world", "TypeScript", { caseSensitive: false }));
// "Hello TypeScript"

// Regex mode — replace all numbers
console.log(findReplace("abc123def456", "\\d+", "NUM", { regex: true }));
// "abcNUMdefNUM"

Learn more: Find and Replace Tool · How to Find and Replace with Regex · Regex Cheat Sheet Essential Patterns

Deduplication

Remove duplicate lines while preserving original order.

import { dedupeLines } from "peasytext";

console.log(dedupeLines("apple\nbanana\napple\ncherry\nbanana"));
// "apple\nbanana\ncherry"

Learn more: Remove Duplicate Lines Tool · How to Remove Duplicate Lines

Line Numbers

Add or remove line numbers from text.

import { addLineNumbers, removeLineNumbers } from "peasytext";

console.log(addLineNumbers("first\nsecond\nthird"));
// "1: first\n2: second\n3: third"

console.log(removeLineNumbers("1: first\n2: second\n3: third"));
// "first\nsecond\nthird"

Learn more: Line Numbers Tool · What is Plain Text? · What is Whitespace?

Pattern Extraction

Extract emails, URLs, phone numbers, IP addresses, hashtags, and @mentions from any text using built-in regex patterns.

import { extract } from "peasytext";

const text = "Contact [email protected], visit https://example.com, call +1-555-0123";
console.log(extract(text, "emails"));   // ["[email protected]"]
console.log(extract(text, "urls"));     // ["https://example.com,"]
console.log(extract(text, "phones"));   // ["+1-555-0123"]

Learn more: Text Extractor Tool · How to Extract Data from Text · Regex Practical Guide

Text Diffing

Compare two texts line by line and measure similarity.

import { diffTexts } from "peasytext";

const result = diffTexts("apple\nbanana\ncherry", "banana\ncherry\ndate");
console.log(result.added);       // ["date"]
console.log(result.removed);     // ["apple"]
console.log(result.similarity);  // 0.6667

Learn more: Text Diff Tool · What is Text Diff? · What is String Distance?

Lorem Ipsum

Generate placeholder text by words, sentences, or paragraphs.

import { loremIpsum } from "peasytext";

console.log(loremIpsum(10, "words"));       // 10 lorem ipsum words
console.log(loremIpsum(3, "paragraphs"));   // 3 paragraphs of text

Learn more: Lorem Ipsum Generator · Lorem Ipsum Placeholder Text Guide · What is Lorem Ipsum?

JSON Formatting

Format, minify, and validate JSON strings.

import { jsonFormat, jsonMinify, jsonValidate } from "peasytext";

console.log(jsonFormat('{"a":1,"b":2}'));   // Pretty-printed with 2-space indent
console.log(jsonMinify('{ "a": 1 }'));      // '{"a":1}'
console.log(jsonValidate('{"key": "ok"}')); // true

Learn more: JSON Formatter Tool · What is Text Encoding? · JSON Format Reference

Text Reversal

Reverse text by characters, words, or lines.

import { reverseText } from "peasytext";

console.log(reverseText("hello", "characters"));     // "olleh"
console.log(reverseText("hello world", "words"));     // "world hello"
console.log(reverseText("a\nb\nc", "lines"));         // "c\nb\na"

Learn more: Reverse Text Tool · What is ROT13? · What is Unicode?

API Reference

| Function | Description | |----------|-------------| | toCase(text, target) | Convert between 13 case formats | | slugify(text, options?) | Generate URL-friendly slug | | countText(text, wpm?) | Count words, chars, sentences, reading time | | sortLines(text, mode?) | Sort lines by alpha, length, numeric, etc. | | base64Encode(text) | Encode text to Base64 (UTF-8 safe) | | base64Decode(text) | Decode Base64 to text (UTF-8 safe) | | urlEncode(text, plus?) | URL-encode text | | urlDecode(text) | URL-decode text | | htmlEncode(text) | Encode HTML entities | | htmlDecode(text) | Decode HTML entities | | findReplace(text, find, replace?, opts?) | Find and replace with regex support | | dedupeLines(text, caseSensitive?) | Remove duplicate lines | | addLineNumbers(text, opts?) | Add line numbers | | removeLineNumbers(text) | Remove line numbers | | extract(text, patternType?) | Extract emails, URLs, phones, etc. | | diffTexts(textA, textB) | Compare two texts | | loremIpsum(count?, unit?) | Generate Lorem Ipsum | | reverseText(text, mode?) | Reverse by chars, words, or lines | | jsonFormat(text, indent?) | Pretty-print JSON | | jsonMinify(text) | Minify JSON | | jsonValidate(text) | Validate JSON |

TypeScript Types

All types are exported for full type safety:

import type {
  CaseType,        // "upper" | "lower" | "title" | "sentence" | "camel" | ...
  SortMode,        // "alpha" | "alpha-desc" | "length" | "numeric" | "reverse" | "shuffle"
  ExtractType,     // "emails" | "urls" | "phones" | "numbers" | "ips" | "hashtags" | "mentions"
  LoremUnit,       // "words" | "sentences" | "paragraphs"
  ReverseMode,     // "characters" | "words" | "lines"
  TextStats,       // { characters, words, sentences, paragraphs, lines, readingTime }
  DiffResult,      // { added, removed, unchanged, similarity }
  SlugifyOptions,  // { separator?, lowercase?, maxLength? }
} from "peasytext";

REST API Client

The API client connects to the PeasyText developer API for tool discovery and content.

import { PeasyTextClient } from "peasytext";

const client = new PeasyTextClient();

// List available tools
const tools = await client.listTools();
console.log(tools.results);

// Search across all content
const results = await client.search("case");
console.log(results);

// Browse the glossary
const glossary = await client.listGlossary({ search: "format" });
for (const term of glossary.results) {
  console.log(`${term.term}: ${term.definition}`);
}

// Discover guides
const guides = await client.listGuides({ category: "text" });
for (const guide of guides.results) {
  console.log(`${guide.title} (${guide.audience_level})`);
}

Full API documentation at peasytext.com/developers/.

Learn More

Also Available

| Language | Package | Install | |----------|---------|---------| | Python | peasytext | pip install "peasytext[all]" | | Go | peasytext-go | go get github.com/peasytools/peasytext-go | | Rust | peasytext | cargo add peasytext | | Ruby | peasytext | gem install peasytext |

Peasy Developer Tools

Part of the Peasy Tools open-source developer ecosystem.

| Package | PyPI | npm | Description | |---------|------|-----|-------------| | peasy-pdf | PyPI | npm | PDF merge, split, rotate, compress, 21 operations — peasypdf.com | | peasy-image | PyPI | npm | Image resize, crop, convert, compress — peasyimage.com | | peasy-audio | PyPI | npm | Audio trim, merge, convert, normalize — peasyaudio.com | | peasy-video | PyPI | npm | Video trim, resize, thumbnails, GIF — peasyvideo.com | | peasy-css | PyPI | npm | CSS minify, format, analyze — peasycss.com | | peasy-compress | PyPI | npm | ZIP, TAR, gzip compression — peasytools.com | | peasy-document | PyPI | npm | Markdown, HTML, CSV, JSON conversion — peasyformats.com | | peasytext | PyPI | npm | Text case conversion, slugify, word count — peasytext.com |

License

MIT