All articles

Case Converter: why different naming styles exist

Go is one of the few mainstream languages where letter case isn't just a style convention — it's part of the language's actual visibility rules. An identifier starting with an uppercase letter (UserName) is exported and visible outside its package; the same name starting lowercase (userName) is private to the package. No public or private keyword needed — the compiler reads it straight off the first letter's case.

The main styles

  • camelCase — first word lowercase, each following word capitalized, no separators: userName. The standard for variables and functions in JavaScript, Java, and C#.
  • PascalCase — the same, but the first word is capitalized too: UserName. Used for classes and components almost everywhere, and doubles as Go's "exported" marker.
  • snake_case — words joined by underscores, all lowercase: user_name. The standard in Python and for database column names.
  • kebab-case — words joined by hyphens: user-name. The standard for URLs, CSS classes, and HTML attributes, since underscores are less common in URLs.

Why this isn't just aesthetics

In most languages, casing has no runtime effect at all — it's purely a readability convention enforced by team style guides, linters, and IDE autocomplete rather than the compiler. Go is the outlier that turns the convention into semantics, which is exactly why a Go developer who renames userName to UserName without meaning to can accidentally make an internal field part of a package's public API.

Why conversion is needed

  • Mapping a field from a JSON API (usually camelCase) to a database column name (usually snake_case).
  • Renaming variables when porting code from one language to another with a different convention.
  • Generating a URL-safe slug or CSS class from a heading's text.

Ambiguity with abbreviations

An identifier like userID or XMLParser forces the converter to make a choice: treat the abbreviation as a single "word," or split it into individual letters. Different tools handle this differently — this converter recognizes a run of capital letters as a separate word (XMLParserXML + Parser), but it's worth checking the result by hand if the name is going straight into production code.

Try the tool