New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

format-strings-ninja

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-strings-ninja

Format strings like a ninja — slug, cases, accents removal, HTML cleaning, smart titles, counts, etc.

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

🥷 format-strings-ninja

Format your strings like a ninja — fast, precise, and dependency-free.

  • ✅ Works in TypeScript and JavaScript
  • ✅ Supports Node.js (CommonJS) and browsers (ES2015)
  • No dependencies
  • Tree-shakeable exports
import { format } from "format-strings-ninja";

format.toSlug("Hello World!");              // "hello-world"
format.titleSmart("the lord of the rings"); // "The Lord of the Rings"

Installation

npm i format-strings-ninja
# or
pnpm add format-strings-ninja
# or
yarn add format-strings-ninja

Usage

In TypeScript / ESM

import { format } from "format-strings-ninja";

console.log(format.camelCase("Hello brave world")); // "helloBraveWorld"
console.log(format.toTitleCase("the quick brown fox")); // "The Quick Brown Fox"

In Node (CommonJS)

const format = require("format-strings-ninja");

console.log(format.toSlug("Hello World!")); // "hello-world"
console.log(format.capitalize("ninja"));    // "Ninja"

In Browser (bundler or CDN)

<script type="module">
  import { format } from "https://esm.sh/format-strings-ninja";
  console.log(format.randomCase("hello ninja world"));
</script>

🧩 API — format

🔤 Basics

FunctionExampleOutput
removeAccents(str)"canción""cancion"
normalizeWhitespace(str)" Hello world ""Hello world"
reverse(str)"ninja""ajnin"
stripNonAscii(str)"héllö 🌎""hell "

🧠 Case & Titles

FunctionExampleOutput
capitalize(str)"ninja""Ninja"
toTitleCase(str)"the quick brown fox""The Quick Brown Fox"
toSentenceCase(str)"hello world""Hello world"
titleSmart(str)"the lord of the rings""The Lord of the Rings"
nameCase(str)"jUAN pérez roJas""Juan Pérez Rojas"

🪶 Slug & Cases

FunctionExampleOutput
toSlug(str)"Hello World!""hello-world"
kebabCase(str)"Hello Ninja World""hello-ninja-world"
snakeCase(str)"Hello Ninja World""hello_ninja_world"
camelCase(str)"Hello ninja world""helloNinjaWorld"

✂️ Trim & Pad

FunctionExampleOutput
truncate(str, len)"This text is too long", 10"This te..."
limitWords(str, count)"This is an example text", 3"This is an..."
pad(str, length, char)"42", 6, "0""002420"
wrap(str, width)"This text is too long", 8"This text\nis too\nlong"

🧹 Clean & Count

FunctionExampleOutput
cleanHTML(html)"<p>Hello <b>world</b></p>""Hello world"
countWords(str)"The ninja writes code"4
countOccurrences(str, sub)"banana", "na"2

🎭 Fun & Stylized

FunctionExampleOutput
randomCase(str)"ninja""nInJa" (random)
alternatingCase(str)"ninja""NiNjA"
stylize(str, "upper")"ninja""NINJA"
stylize(str, "lower")"NINJA""ninja"
stylize(str, "leet")"hacker""h4ck3r"
stylize(str, "weird")"ninja""ñïñjä"

⚙️ Scripts

npm run build-browser  # Build ES2015 modules for browsers (dist-browser/)
npm run build-node    # Build CommonJS modules for Node.js (dist-node/)
npm run build         # Build both browser and Node.js versions

🪪 License

MIT © Freddy Vincenty

Keywords

string

FAQs

Package last updated on 27 Oct 2025

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