Which Naming Style to Use for Code and URLs
One label, five destinations. Map a product name to the style each layer of the stack actually expects.
Start from the destination, not the slogan
camelCase, PascalCase, snake_case, kebab-case, and CONSTANT_CASE all remove spaces. They disagree on the first letter and the separator. Pick the style the file already uses. A JavaScript variable, a React component, a Python function, a URL, and an environment variable should not share one spelling.
One label, five results
Take the label Order Line Item. A JavaScript variable or JSON key becomes orderLineItem. A class or React component becomes OrderLineItem. A Python function or SQL column becomes order_line_item. A URL slug or CSS class becomes order-line-item. An environment variable becomes ORDER_LINE_ITEM. Convert the symbol, then proofread it. Do not run the whole marketing sentence through the converter.
Acronyms need a second look
Mechanical conversion lowercases or capitalizes by word boundaries. HTTP response code may become httpResponseCode, HttpResponseCode, or http_response_code. Some teams keep the acronym in caps inside PascalCase (HTTPResponse) and some do not. The team style guide wins. The converter gives you a consistent draft.
Do not mix styles in one payload
An API that returns userId next to user_name forces every client to guess. Document one style per boundary: camelCase in JSON, snake_case in the database, kebab-case in the URL. Convert at the boundary instead of letting both spellings leak into the same object.
Pairwise guides for the close calls
When two styles look similar, read the narrower comparison. PascalCase versus camelCase is the first-letter rule for types versus variables. kebab-case versus snake_case is the hyphen versus underscore rule for URLs versus columns. This page is the map. Those posts are the arguments.
Pick a style by destination
| Style | Example | Use it for |
|---|---|---|
| camelCase | orderLineItem | JavaScript variables, functions, and JSON keys |
| PascalCase | OrderLineItem | Classes, React components, and types |
| snake_case | order_line_item | Python, Ruby, and SQL columns |
| kebab-case | order-line-item | URL slugs, CSS classes, and CLI flags |
| CONSTANT_CASE | ORDER_LINE_ITEM | Environment variables and constants |
Related Articles: camelCase Converter • PascalCase Converter • snake_case Converter • kebab-case Converter • CONSTANT_CASE Converter • PascalCase vs camelCase • kebab-case vs snake_case
Frequently asked questions
Which style should a URL use?
Use lowercase kebab-case for public URL slugs. Keep snake_case in the database and camelCase in JavaScript.
Which style should an environment variable use?
Use CONSTANT_CASE, also called SCREAMING_SNAKE_CASE, for env vars and many constants. Do not use camelCase for secrets in the environment.
Should I convert a whole sentence?
No. Convert the identifier. Leave the visible headline in title case or sentence case.