camelCase π« vs kebab-case π― for File & Folder Names β
Naming conventions can shape readability, portability, and dev ergonomics. When it comes to file and folder names, the two common contenders are camelCase and kebab-case. Hereβs a head-to-head breakdown to help you choose the right one for your projects.
π₯οΈ Cross-Platform Compatibility β
camelCase
β Can be risky across case-sensitive systems. For example, MyFile.ts and myfile.ts are treated as different files on macOS/Linux, but the same on Windows.
kebab-case
β
Lowercase and hyphenated β no casing ambiguity. It behaves consistently across all operating systems and avoids weird Git diffs.
Verdict: kebab-case is safer and more reliable in team environments.
ποΈ Readability β
camelCase
π€·ββοΈ Acceptable in code, but filenames like myAwesomeComponent.tsx arenβt easy to scan.
kebab-case
β
Clearly separates words. my-awesome-component.tsx is easier to skim in long directory trees.
Verdict: kebab-case wins for visual clarity.
π Web and CLI Friendliness β
camelCase
β Not ideal in URLs or shell commands. May require shift key usage and can look awkward in slugs.
kebab-case
β
Designed for web paths and CLI usage. Works great in /routes/get-started or terminal commands like vite-plugin-name.
Verdict: kebab-case is cleaner for URLs and command-line tools.
π§± Ecosystem Convention β
camelCase
π‘ Common for JavaScript variables and functions, but rare in file names.
kebab-case
β
Standard in open-source: npm packages (react-router, eslint-config-prettier), GitHub repos, CLI tools, etc.
Verdict: kebab-case aligns with ecosystem norms.
π§ Context Clarity β
camelCase
π Might blur the line between code identifiers and files.
kebab-case
β
Clearly signals βthis is a file or folder,β not a function or variable.
Verdict: kebab-case offers better contextual separation.
β Final Take β
Stick with camelCase for code (variables, functions, props)
Use kebab-case for files and folders
Itβs simpler, safer, easier to type, and aligns with modern tooling.
π TL;DR β
| Aspect | camelCase π« | kebab-case π― | Winner |
|---|---|---|---|
| Cross-platform safety | β Risky | β Safe | kebab-case |
| Readability | π€·ββοΈ Okay | β Clear | kebab-case |
| CLI/URL friendliness | β Clunky | β Smooth | kebab-case |
| Ecosystem alignment | β Rare | β Common | kebab-case |
| Code/file distinction | π Mixed | β Obvious | kebab-case |
