case_convert
Convert strings between casing styles like camelCase, snake_case, kebab-case, and others to standardize text formatting in code and documents.
Instructions
Convert a string between different casing styles: camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, and more.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The string to convert | |
| to | Yes | Target case style |
Implementation Reference
- src/tools/text.ts:116-183 (handler)Registration and implementation of the 'case_convert' MCP tool.
server.tool( "case_convert", "Convert a string between different casing styles: camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, and more.", { input: z.string().describe("The string to convert"), to: z .enum([ "camelCase", "PascalCase", "snake_case", "kebab-case", "CONSTANT_CASE", "Title Case", "lowercase", "UPPERCASE", ]) .describe("Target case style"), }, async ({ input, to }) => { // Tokenize: split on spaces, hyphens, underscores, and camelCase boundaries const words = input .replace(/([a-z])([A-Z])/g, "$1 $2") .replace(/[_\-]+/g, " ") .split(/\s+/) .filter((w) => w.length > 0) .map((w) => w.toLowerCase()); let result: string; switch (to) { case "camelCase": result = words .map((w, i) => i === 0 ? w : w.charAt(0).toUpperCase() + w.slice(1) ) .join(""); break; case "PascalCase": result = words .map((w) => w.charAt(0).toUpperCase() + w.slice(1)) .join(""); break; case "snake_case": result = words.join("_"); break; case "kebab-case": result = words.join("-"); break; case "CONSTANT_CASE": result = words.join("_").toUpperCase(); break; case "Title Case": result = words .map((w) => w.charAt(0).toUpperCase() + w.slice(1)) .join(" "); break; case "lowercase": result = words.join(" "); break; case "UPPERCASE": result = words.join(" ").toUpperCase(); break; default: result = input; } return { content: [{ type: "text" as const, text: result }] }; } );