belun.app Blog
RU
· updated

Case Styles Cheat Sheet: camelCase to kebab-case

Every text case style in one table — camelCase, PascalCase, snake_case, kebab-case, dot.case and more, with examples and which language expects which.

Typography and letters in different font styles — text case conversion

A case style is the rule that decides which letters in a phrase are capitalised and what — if anything — sits between the words. About a dozen are in everyday use. Here is every one of them, writing the same three words each time.

Every case style at a glance

Style user account settings becomes Also called Typical use
UPPER CASE USER ACCOUNT SETTINGS all caps Acronyms, legal headings
lower case user account settings lowercase Prose, plain text
Title Case User Account Settings headline case, start case English book and article titles
Sentence case User account settings — UI copy, modern headings
camelCase userAccountSettings lower camel case, dromedary case JS, Java, Swift variables
PascalCase UserAccountSettings upper camel case, CapWords, StudlyCaps Classes, types, components
snake_case user_account_settings pothole case Python, Ruby, DB columns
SCREAMING_SNAKE_CASE USER_ACCOUNT_SETTINGS CONSTANT_CASE, upper snake case Constants, environment variables
kebab-case user-account-settings spinal case, lisp case, dash case CSS classes, URL slugs, filenames
Train-Case User-Account-Settings HTTP-Header-Case HTTP header names
COBOL-CASE USER-ACCOUNT-SETTINGS screaming kebab case COBOL, a few config formats
dot.case user.account.settings — Config keys, i18n keys, namespaces
flatcase useraccountsettings — Go package names, legacy identifiers
aLtErNaTiNg cAsE uSeR aCcOuNt SeTtInGs mocking case, studly caps Memes, nothing serious

The Text Case Converter outputs the first nine minus Train-Case — UPPER, lower, Title, Sentence, camelCase, PascalCase, snake_case and kebab-case — in one click, in your browser.

One name on that list is not a case style at all: small caps. Small caps renders lowercase letters as shrunken capitals, but it is a font feature (font-variant-caps in CSS), not a change to the characters. Copy small-caps text out of a page and you get ordinary lowercase back.

Which case does my language expect?

Conventions are per-language, and almost every language publishes one. Follow it before you follow personal taste — linters, code review and most tooling assume it.

Language Variables & functions Types & classes Constants
Python (PEP 8) snake_case CapWords SCREAMING_SNAKE_CASE
JavaScript / TypeScript camelCase PascalCase SCREAMING_SNAKE_CASE
Java camelCase PascalCase SCREAMING_SNAKE_CASE
C# camelCase locals, PascalCase methods PascalCase PascalCase
Go mixedCaps / MixedCaps if exported MixedCaps MixedCaps — no screaming snake
Rust (RFC 430) snake_case UpperCamelCase SCREAMING_SNAKE_CASE
Ruby snake_case PascalCase SCREAMING_SNAKE_CASE
PHP (PSR-12) camelCase PascalCase SCREAMING_SNAKE_CASE
Swift lowerCamelCase UpperCamelCase lowerCamelCase
SQL snake_case columns — —
CSS kebab-case — --kebab-case custom properties

Go is the one that catches people out. It uses capitalisation for visibility, not decoration: an identifier starting with a capital is exported from its package, one starting lowercase is private. Renaming userID to UserID in Go changes the program, not just the style.

Where the choice is forced on you

In a few places the case style is not a preference — pick the wrong one and something breaks.

URLs — kebab-case. Google reads a hyphen as a word separator and an underscore as a word joiner. blue-widget is indexed as two words someone might search for; blue_widget is one token nobody types. The URL Slug Generator applies this automatically.

Database columns — snake_case. Unquoted identifiers get case-folded by the engine: PostgreSQL lowercases them, Oracle uppercases them. Create a column userId without quotes and Postgres stores userid, so later queries that spell it userId work only by accident. Underscores sidestep the problem entirely.

Environment variables — SCREAMING_SNAKE_CASE. POSIX allows only letters, digits and underscores in a portable variable name, and the convention is uppercase. API-KEY is not a legal shell variable.

Filenames — lowercase kebab-case. macOS and Windows are case-insensitive, Linux is not. Import ./Header.css when the file is header.css and it builds on your laptop and 404s on the deploy server. Lowercase everything and the difference never arises.

HTML and the DOM — kebab-case outside, camelCase inside. A data-user-id attribute is read in JavaScript as dataset.userId. The browser does that conversion for you, in both directions.

JSON and APIs — camelCase or snake_case, but only one. JavaScript ecosystems lean camelCase, Python and Rails lean snake_case. Neither is wrong; mixing both in one payload is. When you are tracking down which keys an endpoint actually returns, run the response through the JSON Formatter first.

Converting between styles

Every conversion is really two steps, and only the first is interesting: split the phrase into words, then rejoin them with the target separator and capitalisation.

Splitting is where naive code fails. You have to break on spaces, _, -, . and / and on a lowercase-to-uppercase boundary, so theQuickBrownFox becomes four words rather than one. Then there is the acronym trap: a run of capitals like XMLHttpRequest needs the split placed before the last capital of the run, not between every letter. Get that wrong and you ship x_m_l_http_request.

Here is what correct splitting produces:

Input camelCase PascalCase snake_case kebab-case
user account settings userAccountSettings UserAccountSettings user_account_settings user-account-settings
theQuickBrownFox theQuickBrownFox TheQuickBrownFox the_quick_brown_fox the-quick-brown-fox
UserAccountSettings userAccountSettings UserAccountSettings user_account_settings user-account-settings
user-account-settings userAccountSettings UserAccountSettings user_account_settings user-account-settings
parseHTTPResponse parseHttpResponse ParseHttpResponse parse_http_response parse-http-response
my file.name.txt myFileNameTxt MyFileNameTxt my_file_name_txt my-file-name-txt

Those are the converter’s real outputs, not idealised ones — any of the six rows can be pasted in and checked.

Note what the acronym rule costs you: parseHTTPResponse comes back as parseHttpResponse, not parseHTTPResponse. That matches C#, whose naming guidelines capitalise only the first letter of any acronym three letters or longer — HtmlButton, not HTMLButton. Python and Go go the other way and keep the acronym whole (HTTPServerError in PEP 8, ServeHTTP in Effective Go), so in those two languages the acronym is the one thing to restore by hand.

Three mistakes worth avoiding

Mixing styles for the same concept. A JavaScript object key userId is not user_id; one of them silently reads back undefined. When data crosses a boundary — JS front end, Python API, SQL table — convert at the boundary, once, in one place.

Capitalising for emphasis. UPPER CASE belongs to acronyms and constants. Three ALL-CAPS words in a paragraph read as shouting, and screen readers may spell some of them out letter by letter.

Title Case on interface copy. Sentence case reads measurably faster and is what Google, Apple and most current style guides specify for buttons, headings and labels. Title Case also forces a judgement call on every and, of and the.

FAQ

Is camel case a font?

No. Camel case is a writing convention, not a typeface — it describes where the capitals go, so any font can display it. The name comes from the humps the capitals make in the middle of a word. If you landed here looking for a typeface, what you probably want is a monospaced coding font; camelCase will look the same in any of them.

What is camelCase format exactly?

Remove the spaces, lowercase the first word, capitalise the first letter of every word after it: user account settings becomes userAccountSettings. No underscores, no hyphens, no other punctuation. If the first letter is also capitalised it is PascalCase, not camelCase.

What is the difference between camelCase and PascalCase?

Only the first letter. userAccountSettings is camelCase, UserAccountSettings is PascalCase. Most languages use camelCase for variables and functions and PascalCase for classes and types, which is why the distinction matters in code review even though it is one character.

Why is it called kebab-case?

Because the hyphens look like a skewer running through the words. It also goes by spinal case, lisp case and dash case; kebab-case is the name that stuck.

Which case should I use for URLs?

kebab-case, lowercase. Hyphens are word separators to search engines, underscores are not, and lowercase avoids duplicate URLs on case-sensitive servers.

Is snake_case the same as SCREAMING_SNAKE_CASE?

Same separator, different capitalisation. snake_case is all lowercase and names variables and functions; SCREAMING_SNAKE_CASE is all uppercase and names constants and environment variables.

Is there an official standard for case styles?

No single one. Unicode defines how individual letters change case, but nothing specifies how words are joined. Each language community publishes its own convention — PEP 8 for Python, RFC 430 for Rust, PSR-12 for PHP, Effective Go for Go — and that convention is what your linter enforces.

Convert in one click

The Text Case Converter takes any text, in any of these styles, and switches it to another — no signup, nothing uploaded, all of it running locally in your browser.

Related text tools that work on strings without touching the words: the Text Reverser for reversed character order and 180°-rotated glyphs, the Whitespace Remover for collapsing stray spaces and blank lines before a conversion, and Find and Replace for bulk edits across a long document.

Try the tool

Text Case Converter →