文本大小写转换器
在 camelCase、PascalCase、snake_case、kebab-case、CONSTANT_CASE 等格式间转换,一次给出全部 14 种结果。
Naming conventions at a glance
| Convention | Example | Typical use |
|---|---|---|
camelCase | userProfileId | JavaScript, Java, Go variables |
PascalCase | UserProfileId | C# classes, React components |
snake_case | user_profile_id | Python, Ruby, SQL columns |
kebab-case | user-profile-id | URLs, CSS classes, CLI flags |
CONSTANT_CASE | USER_PROFILE_ID | Environment variables, constants |
dot.case | user.profile.id | Some config formats, Java packages |
Sentence case | User profile id | Titles and headings |
Why the conventions matter
They are not arbitrary. Python's official style guide mandates snake_case for functions, and PEP 8 exists to make code readable by people who did not write it. The same logic applies to the broader ecosystem: a URL with kebab-case is easier to read aloud, and an env var in CONSTANT_CASE is visually distinct from a normal variable.
The tricky part
Automatic conversion cannot always tell where word boundaries are. userProfileID could reasonably become user_profile_id, user_profile_i_d or user_profileid. The sensible default is to treat a run of capitals as one word — the behaviour used here — but always check the output before shipping it.
Related
Need a URL-friendly version? The slug generator also strips accents and handles non-Latin characters.
常见问题
Which case styles are supported?
Fourteen, including camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, dot.case, slash/case, Title Case and Sentence case.
Which convention should I use?
camelCase for JavaScript and Java variables, PascalCase for C# classes and React components, snake_case for Python and SQL, kebab-case for URLs and CSS, CONSTANT_CASE for environment variables.
Why does it sometimes split a word oddly?
Automatic conversion cannot always tell where word boundaries are. userProfileID could reasonably become user_profile_id or user_profile_i_d. Always check the output.
Does it handle accented characters?
Yes, accents are preserved in the case conversion. Use the slug generator if you need them removed.
Is it reversible?
No. Each conversion is independent, and information such as word boundaries is lost in the process.