What is Train-Case?
Train-Case writes each word with a capital first letter and joins the words with hyphens: Content-Type, User-Agent, Accept-Language. It's kebab-case with capitals, and it's also called HTTP-Header-Case.
Where Train-Case is used
- HTTP header names:
Content-Type,Cache-Control,X-Forwarded-For. This is where most people meet it. - Email header names:
Reply-To,In-Reply-To.
Does capitalization matter in HTTP headers?
No. RFC 9110, the HTTP standard, says field names are case-insensitive, so content-type and Content-Type mean the same thing. Train-Case is a convention for readability, and HTTP/2 sends header names in lowercase on the wire. Some widely used headers also break the pattern, for example WWW-Authenticate and ETag, so copy those names exactly from their specifications.
How Train-Case conversion works
- Input is split into words by the same tokenizer as our other code cases, so camelCase, snake_case and CONSTANT_CASE input all work.
- Each word is lowercased, then its first letter is capitalized.
- Words are joined with a single hyphen.
An acronym is treated as one word, so HTTPServerError becomes Http-Server-Error.
Worked examples
| Input | Train-Case |
|---|---|
content type |
Content-Type |
userAgent |
User-Agent |
X_FORWARDED_FOR |
X-Forwarded-For |
cache-control |
Cache-Control |
HTTPServerError |
Http-Server-Error |
Related case formats
→ Convert text to kebab-case
PascalCase→ Convert text to PascalCase
Capitalized Case→ Capitalize each word
Need more conversion options?
Open the full converter →