Nomus is a naming-style toolkit for Node.js and NestJS. It detects the current style of a string and converts it to formats like UPPERCCASE, lowercase, PascalCase, camelCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, UPPER-KEBAB-CASE, Title Case and Train-Case.
β Convert from any format to:
- UPPERCCASE
- lowercase
- PascalCase
- camelCase
- snake_case
- SCREAMING_SNAKE_CASE
- kebab-case
- UPPER-KEBAB-CASE
- Title Case
- Train-Case
β Automatically detects:
- UPPERCCASE
- lowercase
- PascalCase
- camelCase
- snake_case
- SCREAMING_SNAKE_CASE
- kebab-case
- UPPER-KEBAB-CASE
- Title Case
- Train-Case
- and mixed cases
β Pure TypeScript API for Node.js and TypeScript projects
β Optional NestJS integration exposed as nomus/nest
β ESM, CommonJS, and declaration files ready for npm publishing
β Detects common naming conventions and mixed input
β No runtime dependencies for the core package
npm install nomusFor NestJS integration:
npm install nomus @nestjs/common reflect-metadataNomus is compatible with NestJS 10 projects that already use reflect-metadata@0.1.x, and also with reflect-metadata@0.2.x.
The nomus/nest entrypoint is also published in a way that works with classic TypeScript moduleResolution: node.
import { Naming, detectNamingStyle, toSnakeCase } from "nomus";
detectNamingStyle("votesUsers");
// "camelCase"
toSnakeCase("UserVotesDetails");
// "user_votes_details"
Naming.toTrainCase("helloWorldTest");
// "Hello-World-Test"import { Module } from "@nestjs/common";
import { NomusModule } from "nomus/nest";
@Module({
imports: [NomusModule]
})
export class AppModule {}import { Injectable } from "@nestjs/common";
import { NomusService } from "nomus/nest";
@Injectable()
export class SlugService {
constructor(private readonly nomus: NomusService) {}
formatLabel(value: string) {
return this.nomus.toKebabCase(value);
}
}Static equivalents for all methods
Naming.detectNamingStyle("UserVotesDetails"); // PascalCase
Naming.toTrainCase("userVotesDetails"); // "User-Votes-Details"Automatically detects the naming convention of the text.
'UPPERCASE''lowercase''PascalCase''camelCase''snake_case''SCREAMING_SNAKE_CASE''kebab-case''UPPER-KEBAB-CASE''Title Case''Train-Case''Unknown / Mixed'
Naming.detectNamingStyle("UserVotesDetails"); // PascalCase
detectNamingStyle("userVotesDetails"); // camelCase
Naming.detectNamingStyle("user_votes_details"); // snake_case
detectNamingStyle("user-votes-details"); // kebab-case
Naming.detectNamingStyle("votes UsersDetails"); // Unknown / MixedConverts from any format to UPPERCASE.
Converts from any format to lowercase.
Converts from any format to PascalCase.
Converts from any format to camelCase.
Converts from any format to snake_case.
Converts from any format to SCREAMING_SNAKE_CASE.
Converts from any format to kebab-case.
Converts from any format to UPPER-KEBAB-CASE.
Converts from any format to Title Case.
Converts from any format to Title Case.
Naming.toPascalCase("hello-world"); // HelloWorld
toCamelCase("HELLO_WORLD"); // helloWorld
Naming.toSnakeCase("HelloWorld"); // hello_world
toKebabCase("helloWorldTest"); // hello-world-test
Naming.ToTrainCase("helloWorldTest"); // Hello-World-Test
detectNamingStyle("MyVariable"); // PascalCase
Naming.detectNamingStyle("myVariable"); // camelCase
detectNamingStyle("my_variable"); // snake_case
Naming.detectNamingStyle("my-variable"); // kebab-case
detectNamingStyle("My Variable"); // Title CaseThis project is licensed under the MIT License, which means you can freely use it in commercial and personal projects.
Contributions are welcome! You can:
- Report issues
- Propose improvements
- Submit PRs
If this package was useful to you, consider leaving a β on GitHub or sharing it with other developers.