Skip to content

Guide

Case styles for code and titles

camelCase, snake_case, kebab-case, and CONSTANT_CASE versus title and sentence case — what each convention is for and when to reach for it.

6 min read · updated

The way you join and capitalise words carries meaning that has nothing to do with the words themselves. A programmer reading kebab-case expects a file or a URL; reading CONSTANT_CASE they expect a fixed value that never changes. An editor reading title case expects a heading. These conventions are not arbitrary style — each grew up around a technical constraint or a reader’s expectation, and using the wrong one in the wrong place quietly signals that something is off. This guide covers what each case is for.

The code cases, and why they differ

Programming cannot use spaces to separate words inside a name, because a space usually ends the name. So every code convention is a different answer to the same question: how do you show word boundaries without a space? The answer a language or a context settled on became its convention, and the conventions carry information about what kind of thing you are naming.

  • camelCase joins words and capitalises each after the first: firstName, totalCount. Conventional for variables and functions in JavaScript, Java, and similar languages.
  • PascalCase capitalises every word including the first: FirstName, UserProfile. Conventional for classes, types, and components — the capital signals a “kind of thing” rather than a value.
  • snake_case joins words with underscores: first_name, total_count. Conventional in Python, Ruby, and database column names, where it reads as low-visual-noise.
  • kebab-case joins words with hyphens: first-name, main-content. Used where underscores are awkward or invalid — URLs, CSS classes, filenames, and command-line flags.
  • CONSTANT_CASE is snake_case in capitals: MAX_RETRIES, API_KEY. Reserved for fixed values that do not change while a program runs, so the shout is a signal to the reader.

The distinctions matter because they are load-bearing. A hyphen is not valid in a variable name in most languages, which is why code uses camelCase or snake_case there and saves kebab-case for URLs and CSS. Underscores are legal in identifiers but ugly in a URL. Each convention lives where its characters are allowed and its meaning is expected, and moving one out of its home reads as a mistake.

Case ConverterConvert a name between camelCase, PascalCase, snake_case, kebab-case, and CONSTANT_CASE when a value has to move between a variable, a database column, and a URL.

Converting between them cleanly

The reason a converter beats doing it by hand is that the word boundaries have to be detected before they can be rewritten, and that detection is where manual edits go wrong. Turning “getUserID” into snake_case correctly means recognising that “ID” is its own unit, so the result is “get_user_id” rather than “get_user_i_d”. Handling runs of capitals, digits, and existing separators consistently is fiddly to do by eye across a whole list of names and easy to get subtly wrong.

This comes up constantly in real work: a column named in snake_case in a database has to become a camelCase property in application code, and a PascalCase component name has to become a kebab-case filename. Doing the conversion mechanically keeps the boundaries consistent across the whole set, which matters when the names have to match on both sides.

Title case and sentence case

The prose cases answer a different question — not how to join words, but which to capitalise in a heading. Sentence case capitalises only the first word and any proper nouns, exactly as a normal sentence does: “Cleaning up messy lists”. Title case capitalises the principal words and leaves the small ones lowercase: “Cleaning Up Messy Lists”. Both are correct; they belong to different house styles.

The genuinely hard part of title case is the small words. It is not “capitalise every word” — that produces the amateurish look of “Cleaning Up Messy Lists Of Data”. Articles, short conjunctions, and short prepositions stay lowercase unless they open the title. Style guides differ on the exact cutoff, but the AP-style rule of keeping words under four letters lowercase is a sensible default, and applying it consistently is what separates a polished heading from a shouty one.

  • Sentence case is increasingly the default for product UI, documentation, and many modern publications — it reads calmer and is easier to apply consistently.
  • Title case still dominates in journalism, book titles, and formal headings.
  • The mistake to avoid is Start Case — capitalising every single word regardless — which looks like title case done without the rules.
  • Whichever you pick, use it everywhere; mixing sentence-case and title-case headings on one page looks unfinished.
Case ConverterSwitch a heading between sentence case and AP-style title case, which keeps the small words lowercase instead of capitalising everything.

From a title to a URL

There is a common pipeline worth naming: a heading in title or sentence case often needs to become the slug in a URL, which is kebab-case with the punctuation and accents stripped. This is not just a case conversion — it also folds accented letters to plain ASCII, removes apostrophes and commas, drops stop words, and joins what remains with hyphens. Treat it as its own step rather than a case switch, because a slug has rules a heading does not.

Slug GeneratorTurn a finished heading into a clean kebab-case URL slug, folding accents and stripping punctuation as it goes.

All of these conversions run in your browser, so a list of internal variable names, unreleased component names, or an unpublished post title is not sent anywhere to be reformatted. The text is transformed on the page and nothing about it leaves.

Tools in this guide

Search NeatKit

Jump to a tool, a page, or change the theme.