pipr.tools
Pipes
Clean Email Strip formatting from pasted email for clean plain text Clean AI Output Clean plain text from ChatGPT or AI output Decode & Format JWT Decode a JWT and pretty-print header and payload Word Frequency Count word frequency in text

case-convert Convert between camelCase, snake_case, kebab-case, PascalCase

Aa Text
Input0 chars
Output0 chars

Flags

--to select: camel | snake | kebab | pascal | constant default: camel

Examples

Convert Python snake_case to JavaScript camelCase

Usage
"user_profile_settings
access_token_expiry
max_retry_count" | case-convert

Convert spreadsheet headers to camelCase for a database

Usage
"first name
last name
email address
phone number" | case-convert

Convert CSS properties to camelCase for React style objects

Usage
"background-color
font-size
border-radius" | case-convert
View source
(input, opts = {})=>{
                const to = opts.to || "camel";
                const words = input.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").toLowerCase().split(/\s+/).filter(Boolean);
                switch(to){
                    case "camel":
                        return words.map((w, i)=>(i === 0 ? w : w[0].toUpperCase() + w.slice(1))).join("");
                    case "pascal":
                        return words.map((w)=>w[0].toUpperCase() + w.slice(1)).join("");
                    case "snake":
                        return words.join("_");
                    case "kebab":
                        return words.join("-");
                    case "constant":
                        return words.join("_").toUpperCase();
                    default:
                        return input;
                }
            }