A smart utility to convert strings to Title Case — now with advanced rules for small words, punctuation, and CLI support. Lightweight, dependency-free, and ready for Node.js, browsers, or terminal use.
simple-title-case converts plain text into Title Case, with thoughtful support for:
✅ Small words (e.g. and, of, the) ✅ Apostrophes and hyphenated words ✅ Unicode characters (e.g. accented letters) ✅ CLI integration for terminal use ✅ Extra whitespace normalization ✅ Works in Node.js, React, or via shell commands
Install as a dependency:
npm install simple-title-caseInstall globally to use the titlecase command in your terminal:
npm install -g simple-title-caseconst titleCase = require('simple-title-case');
console.log(titleCase("john's big-day at the park"));
// ➜ "John's Big-Day at the Park"import titleCase from 'simple-title-case';
function App() {
const input = "a tale of two cities";
return <h1>{titleCase(input)}</h1>;
// Renders: "A Tale of Two Cities"
}
export default App;titlecase "the quick brown fox"
# ➜ The Quick Brown Foxecho "john's big-day at the park" | titlecase
# ➜ John's Big-Day at the Park| Input | Output |
|---|---|
"the quick brown fox" |
"The Quick Brown Fox" |
"a tale of two cities" |
"A Tale of Two Cities" |
"john's big-day at the park" |
"John's Big-Day at the Park" |
"ÉLÉGANCE and simplicity" |
"Élégance and Simplicity" |
" extra spaces " |
"Extra Spaces" |
"" (empty string) |
"" |
- ✅ No dependencies – Lightweight and fast
- ✅ Smart casing – Skips small words unless first/last
- ✅ Handles punctuation – Apostrophes and hyphens handled correctly
- ✅ Unicode support – Handles accented characters properly
- ✅ Use anywhere – Works in Node.js, frontend, CLI
Small linking words are lowercased unless they are the first or last word:
a, an, and, as, at, but, by, for, in, nor, of, on, or, the, to, up, yet
If you're developing the CLI locally:
npm linkThen you can run it like:
titlecase "linked local usage works!"
# ➜ Linked Local Usage Works!Found a bug or want to contribute? Pull requests and issues are welcome!
- Fork the repo
- Create a feature branch (
git checkout -b feat/your-feature) - Commit with Conventional Commits
- Open a Pull Request
https://github.com/sonumehtaskr/simple-title-case
MIT © Sonu Kumar