Gathering detailed insights and metrics for text-title-case
Gathering detailed insights and metrics for text-title-case
Gathering detailed insights and metrics for text-title-case
Gathering detailed insights and metrics for text-title-case
titleize
Capitalize every word in a string: `unicorn cake` → `Unicorn Cake`
@ckeditor/ckeditor5-case-change
Case change feature for CKEditor 5.
text-case
Convert text between `camelCase`, `PascalCase`, `Capital Case`, `Header-Case`, `Title Case`, `path/case`, `snake_case`, `param-case`, `dot.case`, `CONSTANT_CASE`, `lower case`, `lOWER CASE FIRST`, `UPPER CASE`, `Upper case first` and other
text-capital-case
Convert into a space separated text with each word capitalized
Convert text between `camelCase`, `PascalCase`, `Capital Case`, `Header-Case`, `Title Case`, `path/case`, `snake_case`, `param-case`, `dot.case`, `CONSTANT_CASE`, `lower case`, `lOWER CASE FIRST`, `UPPER CASE`, `Upper case first` and other
npm install text-title-case
Typescript
Module System
Node Version
NPM Version
TypeScript (99.18%)
TeX (0.82%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
8 Stars
102 Commits
2 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Jun 06, 2025
Latest Version
1.2.4
Package Id
text-title-case@1.2.4
Unpacked Size
15.16 kB
Size
5.47 kB
File Count
7
NPM Version
lerna/8.2.2/node@v22.14.0+x64 (linux)
Node Version
22.14.0
Published on
Jun 03, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
The ultimate text case transformation library for JavaScript and TypeScript. Convert text between
camelCase
,PascalCase
,snake_case
,kebab-case
,CONSTANT_CASE
,Title Case
,Sentence case
,dot.case
,path/case
,Header-Case
, and many more formats with comprehensive TypeScript support.
1# npm 2npm install text-case 3 4# yarn 5yarn add text-case 6 7# pnpm 8pnpm add text-case 9 10# bun 11bun add text-case
1# Install only what you need 2npm install text-camel-case text-kebab-case text-snake-case
1import { 2 camelCase, // userProfileData 3 pascalCase, // UserProfileData 4 kebabCase, // user-profile-data 5 snakeCase, // user_profile_data 6 titleCase, // User Profile Data 7 sentenceCase, // User profile data 8 constantCase, // USER_PROFILE_DATA 9 dotCase, // user.profile.data 10 pathCase, // user/profile/data 11 headerCase, // User-Profile-Data 12 capitalCase, // User Profile Data 13 noCase, // user profile data 14 upperCase, // USER PROFILE DATA 15 lowerCase, // user profile data 16 upperCaseFirst, // User profile data 17 lowerCaseFirst, // user Profile Data 18 swapCase, // uSER pROFILE dATA 19 isUpperCase, // Boolean check 20 isLowerCase, // Boolean check 21} from "text-case"; 22 23// Transform any text format 24const input = "user_profile_data"; 25 26console.log(camelCase(input)); // "userProfileData" 27console.log(pascalCase(input)); // "UserProfileData" 28console.log(kebabCase(input)); // "user-profile-data" 29console.log(titleCase(input)); // "User Profile Data"
Package | Output Example | Use Cases | Size | NPM |
---|---|---|---|---|
text-camel-case | userProfileData | JavaScript variables, object properties | ~450B | |
text-pascal-case | UserProfileData | Class names, components, types | ~400B | |
text-snake-case | user_profile_data | Database columns, Python variables | ~300B | |
text-kebab-case | user-profile-data | CSS classes, URLs, HTML attributes | ~350B | |
text-title-case | User Profile Data | Headers, titles, proper nouns | ~350B | |
text-sentence-case | User profile data | Sentences, descriptions | ~320B |
Package | Output Example | Use Cases | Size | NPM |
---|---|---|---|---|
text-constant-case | USER_PROFILE_DATA | Environment variables, constants | ~380B | |
text-dot-case | user.profile.data | Object paths, file names | ~280B | |
text-path-case | user/profile/data | File paths, URLs | ~300B | |
text-header-case | User-Profile-Data | HTTP headers, train-case | ~340B | |
text-capital-case | User Profile Data | Business titles, formal text | ~330B | |
text-no-case | user profile data | Search queries, plain text | ~280B | |
text-param-case | user-profile-data | URL parameters, kebab-case alias | ~350B |
Package | Output Example | Use Cases | Size | NPM |
---|---|---|---|---|
text-upper-case | USER PROFILE DATA | Constants, emphasis | ~120B | |
text-lower-case | user profile data | Normalization, search | ~120B | |
text-upper-case-first | User profile data | Sentences, proper formatting | ~130B | |
text-lower-case-first | user Profile Data | camelCase conversion | ~130B | |
text-swap-case | uSER pROFILE dATA | Creative text, obfuscation | ~140B |
Package | Output Example | Use Cases | Size | NPM |
---|---|---|---|---|
text-is-upper-case | true/false | Input validation, conditionals | ~100B | |
text-is-lower-case | true/false | Input validation, conditionals | ~100B |
All transformation functions accept an optional second parameter for customization:
1import { camelCase, snakeCase } from "text-case"; 2 3// Custom word splitting 4camelCase("XMLHttpRequest", { 5 splitRegexp: /([a-z])([A-Z])/g, 6}); // "xmlHttpRequest" 7 8// Custom character stripping 9snakeCase("hello@world.com", { 10 stripRegexp: /[@.]/g, 11}); // "hello_world_com" 12 13// Custom transformations 14camelCase("api-v2-endpoint", { 15 transform: (word, index) => { 16 if (word === "api") return "API"; 17 if (word === "v2") return "V2"; 18 return word; 19 }, 20}); // "APIV2Endpoint"
Full TypeScript support with comprehensive type definitions:
1import { camelCase, PascalCase, Options } from "text-case"; 2 3// Type-safe options 4const options: Options = { 5 splitRegexp: /([a-z])([A-Z])/g, 6 stripRegexp: /[^a-zA-Z0-9]/g, 7 transform: (word: string, index: number, words: string[]) => 8 word.toLowerCase(), 9}; 10 11// Type inference 12const result: string = camelCase("hello-world", options); 13 14// Generic type support for consistent transformations 15function transformKeys<T extends Record<string, any>>( 16 obj: T, 17 transformer: (key: string) => string, 18): Record<string, T[keyof T]> { 19 return Object.fromEntries( 20 Object.entries(obj).map(([key, value]) => [transformer(key), value]), 21 ); 22} 23 24const data = { user_name: "John", email_address: "john@example.com" }; 25const camelData = transformKeys(data, camelCase); 26// { userName: "John", emailAddress: "john@example.com" }
1import { camelCase, snakeCase, kebabCase } from "text-case"; 2 3// Convert database columns to JavaScript 4const dbUser = { 5 first_name: "John", 6 last_name: "Doe", 7 email_address: "john@example.com", 8}; 9const jsUser = Object.fromEntries( 10 Object.entries(dbUser).map(([key, value]) => [camelCase(key), value]), 11); 12// { firstName: "John", lastName: "Doe", emailAddress: "john@example.com" } 13 14// Generate API endpoints 15const createEndpoint = (resource, action) => 16 `/api/${kebabCase(resource)}/${kebabCase(action)}`; 17 18createEndpoint("UserProfile", "GetById"); // "/api/user-profile/get-by-id"
1import { pascalCase, camelCase } from "text-case"; 2 3// Component generation 4const createComponent = (name) => ` 5 import React from 'react'; 6 7 interface ${pascalCase(name)}Props { 8 ${camelCase(name)}Data?: any; 9 } 10 11 export const ${pascalCase(name)}: React.FC<${pascalCase(name)}Props> = ({ ${camelCase(name)}Data }) => { 12 return <div>{/* ${pascalCase(name)} component */}</div>; 13 }; 14`; 15 16console.log(createComponent("user_profile_card"));
1import { camelCase } from "text-case"; 2 3// Convert CSS properties 4const cssToJS = (cssText) => { 5 return cssText.replace( 6 /([a-z])-([a-z])/g, 7 (match, p1, p2) => p1 + p2.toUpperCase(), 8 ); 9}; 10 11const styles = { 12 backgroundColor: "#fff", // from background-color 13 fontSize: "16px", // from font-size 14 marginTop: "10px", // from margin-top 15};
1import { constantCase, camelCase } from "text-case"; 2 3// Environment variables to config object 4const envToConfig = (envVars) => { 5 return Object.fromEntries( 6 Object.entries(envVars) 7 .filter(([key]) => key.startsWith("APP_")) 8 .map(([key, value]) => [camelCase(key.replace("APP_", "")), value]), 9 ); 10}; 11 12const env = { 13 APP_DATABASE_URL: "postgres://...", 14 APP_API_SECRET_KEY: "secret123", 15 APP_MAX_FILE_SIZE: "10MB", 16}; 17 18const config = envToConfig(env); 19// { databaseUrl: "postgres://...", apiSecretKey: "secret123", maxFileSize: "10MB" }
1import express from "express"; 2import { kebabCase } from "text-case"; 3 4const app = express(); 5 6// Auto-generate kebab-case routes 7const createRoute = (name, handler) => { 8 app.get(`/${kebabCase(name)}`, handler); 9}; 10 11createRoute("getUserProfile", (req, res) => res.json({ profile: {} })); 12// Creates route: GET /get-user-profile
1// pages/[...slug].js 2import { pathCase } from "text-case"; 3 4export async function getStaticPaths() { 5 const pages = ["About Us", "Contact Form", "Privacy Policy"]; 6 7 return { 8 paths: pages.map((page) => ({ 9 params: { slug: pathCase(page).split("/") }, 10 })), 11 fallback: false, 12 }; 13}
1import { pascalCase } from "text-case"; 2 3// Dynamic component registration 4const components = ["UserCard", "ProductList", "CheckoutForm"]; 5 6components.forEach((name) => { 7 app.component(pascalCase(name), () => import(`./components/${name}.vue`)); 8});
Each package includes comprehensive test suites with:
1# Run all tests 2pnpm test 3 4# Run tests for specific package 5pnpm --filter text-camel-case test 6 7# Run tests with coverage 8pnpm test --coverage 9 10# Run tests in watch mode 11pnpm test --watch
Package | Minified | Gzipped | Tree-shakeable |
---|---|---|---|
text-case (all) | ~8KB | ~3KB | ✅ |
Individual packages | 100B-450B | 50B-250B | ✅ |
Import only what you need for optimal bundle size:
1// ❌ Imports entire library (~8KB) 2import { camelCase } from "text-case"; 3 4// ✅ Imports only camelCase (~450B) 5import { camelCase } from "text-camel-case";
1interface Options { 2 // RegExp to split input into words 3 splitRegexp?: RegExp; 4 5 // RegExp to strip unwanted characters 6 stripRegexp?: RegExp; 7 8 // Custom word transformation function 9 transform?: (word: string, index: number, words: string[]) => string; 10 11 // Custom split function (alternative to splitRegexp) 12 split?: (value: string) => string[]; 13 14 // Delimiter between words (for spaced formats) 15 delimiter?: string; 16}
1// Split on camelCase and PascalCase boundaries 2const camelSplit = { splitRegexp: /([a-z])([A-Z])/g }; 3 4// Preserve numbers as separate words 5const numberSplit = { splitRegexp: /([a-zA-Z])(\d)/g }; 6 7// Strip special characters 8const stripSpecial = { stripRegexp: /[^a-zA-Z0-9]/g }; 9 10// Custom acronym handling 11const acronymTransform = { 12 transform: (word) => { 13 const acronyms = ["API", "URL", "HTTP", "JSON", "XML"]; 14 return acronyms.includes(word.toUpperCase()) ? word.toUpperCase() : word; 15 }, 16};
We welcome contributions! Please see our Contributing Guide for details.
1# Clone the repository 2git clone https://github.com/idimetrix/text-case.git 3cd text-case 4 5# Install dependencies 6pnpm install 7 8# Build all packages 9pnpm build 10 11# Run tests 12pnpm test 13 14# Type check 15pnpm typecheck 16 17# Lint code 18pnpm lint
npx lerna version patch --yes --force-publish=*
npx lerna publish from-package --yes
packages/
├── camel-case/ # camelCase transformation
├── pascal-case/ # PascalCase transformation
├── snake-case/ # snake_case transformation
├── kebab-case/ # kebab-case transformation
├── title-case/ # Title Case transformation
├── sentence-case/ # Sentence case transformation
├── constant-case/ # CONSTANT_CASE transformation
├── dot-case/ # dot.case transformation
├── path-case/ # path/case transformation
├── header-case/ # Header-Case transformation
├── capital-case/ # Capital Case transformation
├── no-case/ # no case transformation
├── param-case/ # param-case transformation
├── upper-case/ # UPPER CASE transformation
├── lower-case/ # lower case transformation
├── upper-case-first/ # Upper case first transformation
├── lower-case-first/ # lower case first transformation
├── swap-case/ # sWaP cAsE transformation
├── is-upper-case/ # UPPER CASE validation
└── is-lower-case/ # lower case validation
Made with ❤️ by Dmitry Selikhov
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More