大小写与命名风格转换
在大写、小写、标题格式、camelCase、PascalCase、snake_case 和 kebab-case 之间转换文本。
Characters
43
Words
9
Lines
1
Every case converter style, and where each one belongs
The same two words in all nine formats this case converter produces:
- UPPERCASE
- Shouting, legal headers, spreadsheet keys that must match exactly. Hard to read in long runs, so keep it short.
- lowercase
- Normalising data before comparing it. Two records only match reliably once both sides are lowercase.
- Title Case
- Headlines, product names, button labels. This converter capitalises every word — a deterministic rule, not an AP one.
- Sentence case
- Body copy, UI microcopy, error messages. Most modern style guides prefer it for anything longer than a few words.
- camelCase
- Variables and functions in JavaScript, Java, Swift. First word stays lowercase so the identifier reads as one token.
- PascalCase
- Classes, types, React components, C# methods. Also called UpperCamelCase.
- snake_case
- Python and Ruby identifiers, SQL columns, JSON keys in Python-flavoured APIs.
- kebab-case
- URLs and slugs, CSS class names, HTML attributes, npm package names. Hyphens survive link underlines; underscores hide under them.
- aLtErNaTiNg
- The mocking-tone meme, or a quick way to make a test string obvious in a log.
Which case does your language actually want?
These are conventions rather than rules — code compiles either way — but linters enforce them and reviewers notice. Python and Ruby take snake_case for variables and functions, PascalCase for classes. JavaScript, Java, Swift take camelCase for variables, PascalCase for classes and React components. Go uses PascalCase to mark an identifier as exported from its package, camelCase to keep it private, so there case is not cosmetic at all — it changes what your code does.
Outside code it is cleaner. CSS class names, URL slugs, npm packages, HTML attributes take kebab-case, because a hyphen survives a link underline where an underscore does not. Environment variables take SCREAMING_SNAKE_CASE. SQL columns are conventionally snake_case, since many databases fold unquoted identifiers to one case anyway, leaving a mixed-case column quoted forever. The awkward seam is JSON between a Python backend and a JavaScript frontend — pick one convention for the wire format, convert at that boundary rather than in three places.
Converting a slug is a slightly different job, because it also has to strip accents and punctuation. The slug generator handles that end to end, and the word counter is the quickest way to check a headline still fits after you switch it to Title Case.
Title case rules: which words stay lowercase
Every style guide agrees on the shape: capitalise the first word, the last word, and all the important words in between. Articles (a, an, the), coordinating conjunctions (and, but, or, nor, for) and short prepositions stay lowercase in the middle. So the is capitalised in a title only when it lands first or last — The Lord of the Rings, not The Lord Of The Rings.
Where guides disagree is prepositions. Chicago lowercases every preposition however long it is, so it writes Walking through Fire. AP capitalises any word of four letters or more, including prepositions, so it writes Walking Through Fire. APA follows the four-letter line too, lowercasing minor words of three letters or fewer — though APA switches to sentence case for titles in a reference list, which trips people up. MLA lowercases articles, prepositions and conjunctions at any length, close to Chicago.
This case converter does not implement any of those, deliberately: it capitalises every word, which is predictable and scriptable. For a headline, convert first and then lowercase the handful of short words by hand — there are rarely more than two or three, and you keep control over the ones a rule would get wrong.
Title Case or Sentence case for headings?
Title Case capitalises the words; Sentence case capitalises the sentence. Both are correct, and the only wrong answer is using each of them somewhere on the same page. Pick one, write it into the style guide, and run everything through the same case converter so it stays consistent.
Sentence case has been winning in product interfaces for a decade. Google, Apple, Microsoft, GOV.UK all specify it for headings, buttons, labels: faster to scan, translates without rework, and it does not turn a long heading into a row of shouted nouns. Title Case still holds for editorial headlines, book and film titles, press releases. Picking today: Sentence case inside an app, Title Case for anything that behaves like a headline. Converting existing copy? Go to Sentence case, then re-capitalise proper nouns by hand.
Three things this case converter cannot guess
Case conversion is a character rule, not a reading of the text, so meaning that lives in the capitals gets lost. These three come up constantly:
- Acronyms get flattened
- NASA launched a probe becomes Nasa Launched A Probe in Title Case, Nasa launched a probe in Sentence case. Nothing marks NASA as an acronym, so it is treated as an ordinary word. Fix those by hand afterwards.
- Sentence case stops at the first sentence
- hello. world again. becomes Hello. world again. — this rule capitalises one character, at the very start, not every character after a full stop.
- Punctuation rides along
- it's a test becomes it'sATest in camelCase, because only spaces, underscores and hyphens count as word breaks. Strip apostrophes and commas first if the result has to be a valid identifier.
大小写与命名风格转换
驼峰、蛇形、烤肉串等风格在多语言仓库中影响一致性;标题大小写在不同语种有停用词规则,本工具偏自动化规则而非报纸体例。
转换后可结合字数统计检查标题长度。
Where it matters less than people fear is in the text your readers see. No search engine ranks a page differently for a heading in Title Case rather than Sentence case. Consistency is the whole argument there: pick one convention, apply it site-wide, and the pages stop looking like five people wrote them.
One limit worth keeping in mind: case conversion is a per-character operation, so it cannot know that NASA is an acronym or that von in a surname stays lowercase. It is also language-sensitive — Turkish has a dotted and a dotless i that uppercase differently from English. Neither will trouble English prose; for user-supplied names, convert with care.
Worked examples
Sentence case “HELLO THERE. how are you? fine!” → “Hello there. How are you? Fine!” camelCase “XMLHttpRequest” → “xmlHttpRequest” snake_case “Hello, world!” → “hello_world” PascalCase “get user ID” → “GetUserId” kebab-case “Crème brûlée recipe” → “crème-brûlée-recipe”
Identifier styles split words at spaces, punctuation, underscores and hyphens, at lower-to-upper case changes, and at the end of an acronym, so XMLHttpRequest becomes three words. Accented and non-Latin letters are kept; strip them with the slug generator if you need ASCII-only identifiers.
Choosing an identifier style
Follow the language or platform convention rather than personal taste: camelCase for JavaScript variables and JSON fields, PascalCase for classes and React components, snake_case for Python, Ruby and most SQL column names, kebab-case for URLs, CSS classes and file names, and UPPER_SNAKE_CASE for constants and environment variables.
Related tools
These free tools pair well with this page — open them in a new tab to finish your workflow.
常见问题
支持哪些文本格式转换?
工具支持大写(UPPERCASE)、小写(lowercase)、标题格式(Title Case)、句首大写(Sentence case)、驼峰式(camelCase)、帕斯卡式(PascalCase)、下划线式(snake_case)、连字符式(kebab-case)和常量式(CONSTANT_CASE)。
camelCase和PascalCase有什么区别?
camelCase中第一个单词小写,后续单词首字母大写(如myVariableName)。PascalCase中每个单词首字母大写(如MyClassName)。PascalCase常用于类名,camelCase常用于变量和函数名。
snake_case用在什么地方?
snake_case用下划线分隔小写单词(如my_variable_name),在Python、Ruby和数据库字段名中很流行,有助于提高多词标识符的可读性。
什么是kebab-case?
kebab-case使用连字符分隔小写单词(如my-variable-name),常用于URL、CSS类名、HTML属性和Web项目中的文件名。
标题格式会大写每个单词吗?
标题格式(Title Case)会将每个单词的首字母大写。某些风格指南(如AP、Chicago)会保留短介词和连词为小写,但此工具采用简单标题格式,将所有单词首字母大写。
转换是可逆的吗?
部分转换会丢失信息。例如,将'myVariable'转为snake_case得到'my_variable',再转回camelCase得到'myVariable'——可以恢复。但将'MY_CONSTANT'转为小写会丢失常量语义。建议始终保留原始文本。