
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
format-strings-ninja
Advanced tools
Format strings like a ninja — slug, cases, accents removal, HTML cleaning, smart titles, counts, etc.
Format your strings like a ninja — fast, precise, and dependency-free.
import { format } from "format-strings-ninja";
format.toSlug("Hello World!"); // "hello-world"
format.titleSmart("the lord of the rings"); // "The Lord of the Rings"
npm i format-strings-ninja
# or
pnpm add format-strings-ninja
# or
yarn add format-strings-ninja
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"
const format = require("format-strings-ninja");
console.log(format.toSlug("Hello World!")); // "hello-world"
console.log(format.capitalize("ninja")); // "Ninja"
<script type="module">
import { format } from "https://esm.sh/format-strings-ninja";
console.log(format.randomCase("hello ninja world"));
</script>
format| Function | Example | Output |
|---|---|---|
removeAccents(str) | "canción" | "cancion" |
normalizeWhitespace(str) | " Hello world " | "Hello world" |
reverse(str) | "ninja" | "ajnin" |
stripNonAscii(str) | "héllö 🌎" | "hell " |
| Function | Example | Output |
|---|---|---|
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" |
| Function | Example | Output |
|---|---|---|
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" |
| Function | Example | Output |
|---|---|---|
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" |
| Function | Example | Output |
|---|---|---|
cleanHTML(html) | "<p>Hello <b>world</b></p>" | "Hello world" |
countWords(str) | "The ninja writes code" | 4 |
countOccurrences(str, sub) | "banana", "na" | 2 |
| Function | Example | Output |
|---|---|---|
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ä" |
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
MIT © Freddy Vincenty
FAQs
Format strings like a ninja — slug, cases, accents removal, HTML cleaning, smart titles, counts, etc.
We found that format-strings-ninja 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.