Registry / devops / string-kit

string-kit

JSON →
library0.19.3jsnpmunverified

A string manipulation toolbox for Node.js (v0.19.3, beta status, MIT license). Provides a sprintf-inspired string formatter with style markup (^caret), a variable inspector with ANSI colors and HTML output, and various escape functions (shell arguments, regex, HTML, control characters). Unlike sprintf libraries, it includes a full inspect utility for debugging objects with color, and supports metrics, scientific notation, time duration, and base64 conversions. Intended for Node.js; browser support is planned but not yet available. Release cadence is irregular; last release was in 2025.

npm install string-kit
INSTALL
IMPORT
SIG · STRING-KIT
S
string-kit
devopsjavascriptv0.19.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
import { format } from 'string-kit'
const format = require('string-kit').format
ESM is supported since v0.19.0; CJS require still works but prefer named import.
inspect
import { inspect } from 'string-kit'
The inspect function is a named export, not default.
escape
import { escape } from 'string-kit'
import { escapeShellArg } from 'string-kit'
escape is an object containing methods like shellArg, regExp, html, etc.
default import
import stringKit from 'string-kit'
import * as stringKit from 'string-kit'
Default import gives the whole module object with format, inspect, escape, etc.

Demonstrates format() with specifiers and markup, inspect(), and escape methods (shellArg, html).

import { format, inspect, escape } from 'string-kit'; // Format string with sprintf-like specifiers console.log(format('Hello %s %s, you are %d years old.', 'Jane', 'Doe', 30)); // Output: 'Hello Jane Doe, you are 30 years old.' // Format with colors and styles using caret markup console.log(format('This is ^rred^ and ^Bblue^.')); // Inspect an object const obj = { name: 'John', age: 25, active: true }; console.log(inspect(obj)); // Output: colored representation of the object // Escape a string for shell argument console.log(escape.shellArg("file's name")); // Output: 'file\'s name' // Escape for HTML console.log(escape.html('<script>alert("xss")</script>')); // Output: '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'
Debug
Known issues
deprecatedThe default export is deprecated in favor of named exports.
fix
Use import { format, inspect, escape } from 'string-kit' instead of import stringKit from 'string-kit'.
affects: >=0.19.0
gotchaThe format() function interprets caret (^) as markup for styles. Literal carets must be escaped as ^^.
fix
Use '^^' to output a single caret character in format strings.
affects: >=0.3.x
gotchaescape.regExp() escapes the string for use as a literal match inside a RegExp, but does not wrap it in forward slashes.
fix
Manually construct the regex: new RegExp(escape.regExp(input)).
affects: >=0.1.0
breakingIn v0.18.x, the module switched to named exports; default export behavior changed.
fix
Update imports from 'const sk = require("string-kit")' to 'const { format, inspect, escape } = require("string-kit")'.
affects: >=0.18.0
gotchaThe inspect() function may output ANSI color codes by default. In non-TTY environments, this can cause garbled output.
fix
Pass options to disable colors, e.g., inspect(obj, { color: false }).
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: stringKit.format is not a function
Using default import incorrectly after version 0.18.0 when named exports were introduced.
fix
Use import { format } from 'string-kit' instead of import stringKit from 'string-kit'.
SyntaxError: Unexpected token '?'
The package uses Node.js features requiring Node >=14.15.0; older Node versions fail.
fix
Upgrade Node.js to version 14.15.0 or higher.
Cannot find module 'string-kit'
Package not installed or install failed due to missing dependencies.
fix
Run 'npm install string-kit' in your project directory.
escape.shellArg is not a function
Importing escape methods directly instead of accessing the escape object.
fix
Use escape.shellArg() after importing { escape } from 'string-kit'.
Upgrade
Version history
0.19.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
string-kit — npm install string-kit · libregistry