HomeProgrammingTrain Case Converter

Online Train Case (Train-Case) Converter Tool

Train case (also called Train-Case or Capital-Kebab-Case) is a naming style where each word starts with a capital letter and words are joined by hyphens, like User-Profile or Api-Version. It looks like train cars linked together, hence the name. This style shines in URLs, CSS class names (especially BEM variants), project naming, and config files. In this guide, we break down its rules, use cases, and how it compares to other naming conventions.

What Is Train Case?

Train case (also written as Train-Case or Capital-Kebab-Case) is a naming convention that mixes hyphen separators with capitalised first letters. Every word begins with an uppercase letter and is joined by a single hyphen, giving each term a distinct, train‑like appearance — for example, User-Profile or Api-Version. This style is particularly useful in project names, URL slugs, CSS class names (especially within BEM), and certain configuration files. Compared to plain lowercase kebab-case, train case offers extra readability and visual emphasis, making it a favourite for branding and public-facing identifiers.

Core Rules of Train Case

Capitalise Each Word, Lowercase the Rest

Every word must start with a capital letter, followed by lowercase letters. This is similar to PascalCase, but with hyphens instead of no separator — e.g., Max-Retry, not max-retry or MAX-RETRY.

Hyphen as Separator

Words are connected by a single hyphen -, as in User-Account. Since hyphens are safe in URLs and carry special meaning in CSS, train case integrates well with those environments.

Handling Acronyms

Common acronyms like API, URL, or ID are often kept fully uppercase (e.g., API-Key, User-ID). However, some teams prefer only the first letter capitalised (Api-Key). Consistency within your project is what matters most.

No Leading, Trailing, or Consecutive Hyphens

A valid train‑case identifier must not start or end with a hyphen, nor contain multiple hyphens in a row.

Where Train Case Shines

Although train case is rarely used for variable names in programming languages (because most languages don’t allow hyphens in identifiers), it excels in other areas:

Project and Package Names

Many open‑source projects and commercial products adopt train case for their names — think My-Project or Awesome-Library. The capital letters make the name stand out more than all‑lowercase alternatives, while hyphens stay compatible with most package managers (e.g., npm technically prefers lowercase, but train case is still common on GitHub repositories).

URL Design

In RESTful APIs or website paths, train case can be used to denote resource collections or versions, like /api/User-Profile or /v1/Order-Item. Though lowercase kebab is more widespread, train case gives URLs an extra layer of readability, especially for branded endpoints.

CSS Class Names (BEM Variants)

Within the BEM (Block Element Modifier) methodology, class names often use hyphens. Some teams adopt train case for Blocks or Elements to differentiate them from modifiers. For instance, .User-Profile could represent a block, while .user-profile--active might stay lowercase. This hybrid approach can be tailored to your project’s needs.

Configuration Keys

Certain configuration formats (JSON, YAML) allow hyphens in keys. Train case makes those keys more readable, e.g., "Max-Retry": 3. Just remember that in many programming languages, you’ll need to quote such keys when accessing them.

Pros and Cons of Train Case

Advantages

  • Excellent readability – capital letters make word boundaries pop, so scanning is faster.
  • Visually polished – the combination of hyphens and capitals looks clean and professional, great for branding.
  • URL‑friendly – hyphens are safe and SEO‑friendly in web addresses.
  • Semantic emphasis – capitalisation suggests nouns or important entities, distinguishing them from plain lowercase terms.
  • No case‑sensitivity pitfalls – unlike camelCase, hyphens remove ambiguity about where words split.

Disadvantages

  • More effort to type – you need to hold Shift for capitals and type hyphens.
  • Not usable for code identifiers – most programming languages don’t allow hyphens in variable or function names.
  • Possible confusion with macro style – macro style uses all caps and underscores, while train case uses caps + hyphens. They look different, but beginners might mix them up.
  • Lack of a universal standard – how to handle acronyms (all caps or just first letter) isn’t fixed; you need a team agreement.

Train Case vs. Other Naming Styles

Train case sits between kebab‑case (all lowercase with hyphens) and PascalCase (no separators, capitalised). It borrows the visual clarity of hyphens from kebab and the emphatic capitals from Pascal, but it sacrifices the simplicity of all‑lowercase. Compared to macro style (all caps + underscores), train case is less shouty and more readable, making it better suited for user‑facing names and UI elements, while macro style stays in the realm of constants.

Next to snake_case (lowercase with underscores), train case feels more prominent and formal, so it’s often chosen for titles and identifiers that need to stand out. In practice, train case typically lives in namespaces, project titles, URL paths, and style hooks — it rarely crosses into internal code.

Best Practices for Using Train Case

  • Agree on a team standard – if you adopt train case, document the rules (including acronym handling) and apply them consistently.
  • Pick the right contexts – use train case for project names, URLs, and CSS classes (where appropriate); avoid it for variables or function names.
  • Keep names concise – overly long names like This-Is-A-Very-Long-Name hurt readability; shorten where possible.
  • Check tooling compatibility – make sure your build pipeline, linters, and editors handle hyphens and capitals correctly.
  • Document everything – add a short note in your project’s README or style guide so newcomers know when and how to use train case.

A Brief History of Train Case

Train case isn’t an official standard from any particular language or framework; it grew out of community practice. The name “Train‑Case” comes from the visual metaphor of train cars (words) linked by couplers (hyphens). It first appeared in early web development as a way to name URL segments, and later found its way into CSS class naming as a variant. Though it never achieved the ubiquity of camelCase or snake_case, its unique readability keeps it alive in niche areas like branding, API design, and documentation.

Final Thoughts

Train case is a naming style that balances clear separation with capital‑letter emphasis. It’s a great fit for project identities, URL paths, and specific style classes. While it won’t replace internal code identifiers, it gives you a visual edge over plain lowercase kebab in the right contexts. Understanding how train case differs from macro style, kebab case, and others helps you make smarter naming decisions — and adds a touch of professionalism to your work.