https://github.com/jahirultusar/javascript-string-utils-lite
string-utils-lite is a tiny, dependency-free JavaScript library that makes common string transformations effortless and consistent across projects.
https://github.com/jahirultusar/javascript-string-utils-lite
javascript npm-package open-source string-utils typescript
Last synced: 2 months ago
JSON representation
string-utils-lite is a tiny, dependency-free JavaScript library that makes common string transformations effortless and consistent across projects.
- Host: GitHub
- URL: https://github.com/jahirultusar/javascript-string-utils-lite
- Owner: jahirultusar
- License: mit
- Created: 2025-08-16T17:42:26.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-08-17T08:19:47.000Z (7 months ago)
- Last Synced: 2025-09-20T06:59:31.240Z (6 months ago)
- Topics: javascript, npm-package, open-source, string-utils, typescript
- Language: HTML
- Homepage: https://www.npmjs.com/package/string-utils-lite
- Size: 198 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# string-utils-lite
[](https://www.npmjs.com/package/string-utils-lite)
[](https://www.npmjs.com/package/string-utils-lite)
[](https://github.com/jahirultusar/JavaScript-string-utils-lite/actions/workflows/ci.yml)
[](https://github.com/jahirultusar/JavaScript-string-utils-lite/actions/workflows/release.yml)
[](./LICENSE)
## ๐ฎ Live Playground
Try the library instantly in your browser:
๐ [Playground Demo](https://jahirultusar.github.io/JavaScript-string-utils-lite/index.html)
## What is `string-utils-lite`?
`string-utils-lite` is a **tiny, dependency-free JavaScript library** that makes common string transformations effortless and consistent across projects.
It provides simple helper functions for everyday string formatting needs:
- `capitalize` โ Uppercases the first character, lowercases the rest
- `titleCase` โ Capitalises the first character of every word
- `toKebabCase` โ Converts text into `kebab-case`
- `toSnakeCase` โ Converts text into `snake_case`
- `toCamelCase` โ Converts text into `camelCase`
- `toPascalCase` โ Converts text into `PascalCase`
---
## ๐ก Why use this library?
JavaScript lacks built-in utilities for string case transformations (unlike Pythonโs `.title()` or `.capitalize()`).
While you could write ad-hoc functions, `string-utils-lite` saves time by offering:
- โ
**Consistency** โ same results across all projects
- โ
**Zero dependencies** โ lightweight, no bloat
- โ
**Dual support** โ works with both **ESM** and **CommonJS**
- โ
**Tree-shakable** โ import only what you need
Whether youโre cleaning up user input, formatting identifiers, or ensuring consistency in APIs, this library provides a clear and minimal solution.
## ๐ฆ Installation
Using npm (recommended):
```bash
npm install string-utils-lite
## ๐ Usage
You can use string-utils-lite in multiple environments:
ES Modules:
import { capitalize, titleCase, toKebabCase } from 'string-utils-lite';
console.log(capitalize('hELLo')); // "Hello"
console.log(titleCase('hELLO woRLD')); // "Hello World"
console.log(toKebabCase('Hello World')); // "hello-world"
CommonJS:
const { capitalize, titleCase } = require('string-utils-lite');
console.log(capitalize('hELLo')); // "Hello"
console.log(titleCase('foo bar')); // "Foo Bar"
CDN (Direct Browser Use):
No installation required! Load from a CDN like esm.sh and use in the browser. For example:
import { capitalize, titleCase } from "https://esm.sh/string-utils-lite";
console.log(capitalize("hELLo")); // "Hello"
console.log(titleCase("hELLO woRLD")); // "Hello World");
## ๐ API Reference
| Function | Description | Example Input | Example Output |
|-------------------|--------------------------------------------------|-----------------|-----------------|
| `capitalize(str)` | Uppercases the first letter, lowercases the rest | `"hELLo"` | `"Hello"` |
| `titleCase(str)` | Capitalises the first letter of each word | `"hELLO woRLD"` | `"Hello World"` |
| `toKebabCase(str)`| Converts string to kebab-case | `"Hello World"` | `"hello-world"` |
| `toSnakeCase(str)`| Converts string to snake_case | `"Hello World"` | `"hello_world"` |
| `toCamelCase(str)`| Converts string to camelCase | `"Hello World"` | `"helloWorld"` |
| `toPascalCase(str)`| Converts string to PascalCase | `"Hello World"` | `"HelloWorld"` |
> โน๏ธ All functions are **pure**: they return a new string without mutating the input.
## ๐งช Running Tests
This project uses Vitest
npm test
## ๐ Development
Clone the repo and install dependencies:
git clone https://github.com/jahirultusar/JavaScript-string-utils-lite.git
cd string-utils-lite
npm install
Build the package:
npm run build
## ๐ค Contributing
Contributions are welcome! ๐
Fork the repository
Create a feature branch (git checkout -b feature/my-feature)
Commit your changes (git commit -m 'feat: add new feature')
Push to the branch (git push origin feature/my-feature)
Open a Pull Request
Please follow Conventional Commits for commit messages.
๐ License
MIT ยฉ 2025 Jahirul Tusar