What is Train-Case, and what is this converter for?
Train-Case is a naming convention where every word in a phrase is capitalized and joined together with hyphens β turning "Content Type" or "contentType" into Content-Type. The name comes from the way each capitalized word looks like a train car linked to the next by a hyphen "coupler." This tool converts any input β plain sentences, hyphenated phrases, or camelCase/PascalCase variable names β into Train-Case instantly, entirely as JavaScript inside your browser. There's no upload and no server round-trip, so your text never leaves your device.
How word boundaries are detected
The converter splits your input wherever a new word logically begins: at spaces, hyphens, underscores, and at the transition from a lowercase letter to an uppercase letter (as in "contentType" β "content" + "Type"). It also handles consecutive capitals correctly, so "XRequestedWith" becomes X-Requested-With rather than X-Requested-With split incorrectly letter by letter. Detected words are then capitalized and rejoined with hyphens.
Train-Case vs. kebab-case vs. PascalCase
Train-Case sits between the two: like kebab-case, it separates words with hyphens; like PascalCase, it capitalizes the first letter of every word. kebab-case keeps everything lowercase (content-type), while PascalCase removes the hyphens entirely (ContentType). Train-Case is the one you'll recognize instantly from HTTP headers.
Where Train-Case is used
- HTTP headers β the defining example:
Content-Type,Cache-Control,X-Requested-With. - COBOL identifiers β historically, COBOL programs commonly used hyphenated, capitalized names for data items.
- CLI flag naming β some command-line tools display flags or option groups in Train-Case for readability.
- Documentation headings β occasionally used to format compact technical labels or table headers.
- Legacy systems & mainframe naming β inherited from environments where hyphens were valid but underscores or camelCase weren't.
Naming convention comparison
| Case style | Example | Common use |
|---|---|---|
| Train-Case | Content-Type | HTTP headers, COBOL identifiers |
| kebab-case | content-type | URL slugs, HTML attributes, CSS classes |
| PascalCase | ContentType | Class names, C#/Java types, React components |
| camelCase | contentType | JavaScript/Java variables & functions |
| snake_case | content_type | Python/Ruby/Rust variables, DB columns |