Case Conversion and Naming Conventions Explained

What each casing convention is for, and the pitfalls when converting between them.

4 min read

Prose cases

Sentence case capitalises only the first word and proper nouns. It is easier to read and is the house style of most modern publications.

Title case capitalises principal words. The rules differ between style guides, particularly for short prepositions, so pick one guide and follow it.

All capitals reduces reading speed measurably and should be reserved for short labels.

Technical cases

camelCase joins words with capitals after the first, and is conventional for variables in JavaScript and Java.

PascalCase capitalises every word including the first, and is conventional for class and component names.

snake_case uses underscores and dominates Python and SQL. kebab-case uses hyphens and is standard for URLs, CSS classes and file names on the web.

Converting safely

Acronyms are where conversion breaks. "parseHTMLResponse" converted mechanically to snake case can produce "parse_h_t_m_l_response". Check acronyms by hand.

Accented characters and non-Latin scripts do not always round-trip through naive case conversion. Verify names and place names after any bulk change.

Never bulk-convert a file that mixes prose and code. Convert the identifiers only.

Choosing for URLs and files

Use lowercase kebab-case for URLs. It is case-insensitive in practice on some servers and not others, and lowercase avoids the whole problem.

Avoid spaces in file names for anything that will be handled by scripts; hyphens or underscores are safer.

Frequently asked questions

Tool for this

TextToolsCount, clean, convert and de-duplicate text.

Open the TextTools page

More in Text Utilities & Processing