[{"data":1,"prerenderedAt":603},["ShallowReactive",2],{"guide-camelcase-vs-snake-case":3},{"id":4,"title":5,"body":6,"date":594,"description":595,"extension":596,"meta":597,"navigation":598,"path":599,"readingTime":252,"seo":600,"stem":601,"__hash__":602},"guides\u002Fguides\u002Fcamelcase-vs-snake-case.md","camelCase vs snake_case: The Great Naming Debate",{"type":7,"value":8,"toc":581},"minimark",[9,14,27,31,42,51,55,62,69,72,76,79,184,188,191,256,283,286,315,318,322,325,357,360,364,367,402,406,497,516,520,540,544,547,557,561,577],[10,11,13],"h2",{"id":12},"two-styles-one-problem","Two Styles, One Problem",[15,16,17,18,22,23,26],"p",{},"Every developer eventually faces this question: should you write ",[19,20,21],"code",{},"firstName"," or ",[19,24,25],{},"first_name","? The answer depends on your language, your team, and — surprisingly — on cognitive science. Let's break down the real differences.",[10,28,30],{"id":29},"origins-of-each-style","Origins of Each Style",[15,32,33,37,38,41],{},[34,35,36],"strong",{},"camelCase"," emerged from early programming languages where spaces were invalid in identifiers. Lisp hackers in the 1960s used hyphens (",[19,39,40],{},"first-name","), but when languages like C and Java reserved the hyphen for subtraction, developers shifted to capitalizing internal words. Smalltalk popularized the style, and Java cemented it as the default for millions of developers.",[15,43,44,47,48,50],{},[34,45,46],{},"snake_case"," has older roots in C and the Unix tradition. Underscores were valid identifier characters and visually separated words without changing letter case. Python adopted snake_case wholesale in the 1990s, and Ruby followed. The style aligns naturally with how people write in plain English when spaces are not available (e.g., ",[19,49,25],{},").",[10,52,54],{"id":53},"what-research-says-about-readability","What Research Says About Readability",[15,56,57,58,61],{},"In 2010, a controlled eye-tracking study by Binkley et al. found that ",[34,59,60],{},"snake_case identifiers were read 20% faster"," than camelCase identifiers on average. The underscores act as visual word boundaries, making it easier for the brain to split the identifier into its component words.",[15,63,64,65,68],{},"However, the study also found that ",[34,66,67],{},"familiarity reduces the gap",". Developers who work primarily in camelCase languages perform almost as well with camelCase as with snake_case. The readability advantage shrinks with daily exposure.",[15,70,71],{},"A later replication by Schankin et al. (2017) confirmed the direction but found a smaller effect size (around 10%). The consensus: snake_case has a measurable edge for new readers, but the difference is small for experienced practitioners in either style.",[10,73,75],{"id":74},"language-ecosystem-choices","Language Ecosystem Choices",[15,77,78],{},"The programming languages you use heavily influence which style feels natural. Here is how the major ecosystems line up.",[80,81,82,98],"table",{},[83,84,85],"thead",{},[86,87,88,92,95],"tr",{},[89,90,91],"th",{},"Ecosystem",[89,93,94],{},"Primary Style",[89,96,97],{},"Reason",[99,100,101,112,122,133,143,153,163,173],"tbody",{},[86,102,103,107,109],{},[104,105,106],"td",{},"JavaScript \u002F TypeScript",[104,108,36],{},[104,110,111],{},"Language spec, DOM APIs, JSON",[86,113,114,117,119],{},[104,115,116],{},"Java \u002F Kotlin",[104,118,36],{},[104,120,121],{},"Official style guides",[86,123,124,127,130],{},[104,125,126],{},"C#",[104,128,129],{},"camelCase \u002F PascalCase",[104,131,132],{},"Microsoft conventions",[86,134,135,138,140],{},[104,136,137],{},"Python",[104,139,46],{},[104,141,142],{},"PEP 8 style guide",[86,144,145,148,150],{},[104,146,147],{},"Ruby",[104,149,46],{},[104,151,152],{},"Community convention",[86,154,155,158,160],{},[104,156,157],{},"Rust",[104,159,46],{},[104,161,162],{},"Compiler-enforced for functions",[86,164,165,168,170],{},[104,166,167],{},"Go",[104,169,36],{},[104,171,172],{},"Export visibility tied to case",[86,174,175,178,181],{},[104,176,177],{},"C \u002F C++",[104,179,180],{},"Mixed",[104,182,183],{},"No single convention dominates",[10,185,187],{"id":186},"the-json-to-python-problem","The JSON-to-Python Problem",[15,189,190],{},"One of the most practical pain points is the mismatch between JSON APIs (camelCase) and Python backends (snake_case). Every Python developer who consumes a JSON API has faced this:",[192,193,198],"pre",{"className":194,"code":195,"language":196,"meta":197,"style":197},"language-json shiki shiki-themes github-light github-dark","{\n  \"firstName\": \"Alice\",\n  \"lastName\": \"Smith\",\n  \"isActive\": true\n}\n","json","",[19,199,200,209,226,239,250],{"__ignoreMap":197},[201,202,205],"span",{"class":203,"line":204},"line",1,[201,206,208],{"class":207},"sVt8B","{\n",[201,210,212,216,219,223],{"class":203,"line":211},2,[201,213,215],{"class":214},"sj4cs","  \"firstName\"",[201,217,218],{"class":207},": ",[201,220,222],{"class":221},"sZZnC","\"Alice\"",[201,224,225],{"class":207},",\n",[201,227,229,232,234,237],{"class":203,"line":228},3,[201,230,231],{"class":214},"  \"lastName\"",[201,233,218],{"class":207},[201,235,236],{"class":221},"\"Smith\"",[201,238,225],{"class":207},[201,240,242,245,247],{"class":203,"line":241},4,[201,243,244],{"class":214},"  \"isActive\"",[201,246,218],{"class":207},[201,248,249],{"class":214},"true\n",[201,251,253],{"class":203,"line":252},5,[201,254,255],{"class":207},"}\n",[192,257,261],{"className":258,"code":259,"language":260,"meta":197,"style":197},"language-python shiki shiki-themes github-light github-dark","# Manual conversion — tedious and error-prone\nfirst_name = data[\"firstName\"]\nlast_name = data[\"lastName\"]\nis_active = data[\"isActive\"]\n","python",[19,262,263,268,273,278],{"__ignoreMap":197},[201,264,265],{"class":203,"line":204},[201,266,267],{},"# Manual conversion — tedious and error-prone\n",[201,269,270],{"class":203,"line":211},[201,271,272],{},"first_name = data[\"firstName\"]\n",[201,274,275],{"class":203,"line":228},[201,276,277],{},"last_name = data[\"lastName\"]\n",[201,279,280],{"class":203,"line":241},[201,281,282],{},"is_active = data[\"isActive\"]\n",[15,284,285],{},"Popular solutions include:",[287,288,289,300,309],"ul",{},[290,291,292,295,296,299],"li",{},[34,293,294],{},"pydantic"," — ",[19,297,298],{},"alias_generator"," config option that maps camelCase to snake_case automatically",[290,301,302,295,305,308],{},[34,303,304],{},"marshmallow",[19,306,307],{},"data_key"," parameter for field-level mapping",[290,310,311,314],{},[34,312,313],{},"Custom deserialization functions"," — Convert keys at the API boundary",[15,316,317],{},"The key principle: convert at the boundary, use native conventions inside. Never let camelCase variables leak deep into a snake_case codebase.",[10,319,321],{"id":320},"database-column-naming","Database Column Naming",[15,323,324],{},"Most SQL databases default to lowercase identifiers, and underscores handle word separation naturally. This makes snake_case the overwhelming convention for database schemas:",[192,326,330],{"className":327,"code":328,"language":329,"meta":197,"style":197},"language-sql shiki shiki-themes github-light github-dark","CREATE TABLE users (\n    first_name VARCHAR(100),\n    last_name VARCHAR(100),\n    created_at TIMESTAMP\n);\n","sql",[19,331,332,337,342,347,352],{"__ignoreMap":197},[201,333,334],{"class":203,"line":204},[201,335,336],{},"CREATE TABLE users (\n",[201,338,339],{"class":203,"line":211},[201,340,341],{},"    first_name VARCHAR(100),\n",[201,343,344],{"class":203,"line":228},[201,345,346],{},"    last_name VARCHAR(100),\n",[201,348,349],{"class":203,"line":241},[201,350,351],{},"    created_at TIMESTAMP\n",[201,353,354],{"class":203,"line":252},[201,355,356],{},");\n",[15,358,359],{},"Object-relational mappers (ORMs) like SQLAlchemy, Django ORM, and ActiveRecord all default to snake_case column names. If your application uses camelCase internally, the ORM typically handles translation at the data layer boundary.",[10,361,363],{"id":362},"handling-mixed-codebases","Handling Mixed Codebases",[15,365,366],{},"Large systems often combine languages. A typical web stack might involve JavaScript (camelCase) on the frontend, Python (snake_case) on the backend, and SQL (snake_case) in the database. Here is how to keep things manageable:",[368,369,370,376,382,388],"ol",{},[290,371,372,375],{},[34,373,374],{},"Follow each language's convention inside its own layer."," Do not write Python in camelCase to match the frontend.",[290,377,378,381],{},[34,379,380],{},"Convert at the boundaries."," API serializers and ORM mappings handle the translation.",[290,383,384,387],{},[34,385,386],{},"Document the mapping convention."," Make it clear where conversion happens so new developers do not duplicate or skip it.",[290,389,390,393,394,397,398,401],{},[34,391,392],{},"Use automated conversion tools."," Libraries like ",[19,395,396],{},"humps"," (Python) or ",[19,399,400],{},"lodash.camelCase"," (JS) handle bulk conversions reliably.",[10,403,405],{"id":404},"practical-comparison","Practical Comparison",[80,407,408,419],{},[83,409,410],{},[86,411,412,415,417],{},[89,413,414],{},"Aspect",[89,416,36],{},[89,418,46],{},[99,420,421,432,443,454,464,475],{},[86,422,423,426,429],{},[104,424,425],{},"Visual density",[104,427,428],{},"Higher (no separator characters)",[104,430,431],{},"Lower (underscores add spacing)",[86,433,434,437,440],{},[104,435,436],{},"Typing speed",[104,438,439],{},"Faster (no underscore key)",[104,441,442],{},"Slightly slower",[86,444,445,448,451],{},[104,446,447],{},"Readability for new readers",[104,449,450],{},"Lower",[104,452,453],{},"Higher (research-backed)",[86,455,456,459,462],{},[104,457,458],{},"Readability for experienced users",[104,460,461],{},"Comparable",[104,463,461],{},[86,465,466,469,472],{},[104,467,468],{},"Language support",[104,470,471],{},"JS, Java, C#, Go",[104,473,474],{},"Python, Ruby, Rust, SQL",[86,476,477,480,491],{},[104,478,479],{},"All-caps handling",[104,481,482,483,486,487,490],{},"Ambiguous (",[19,484,485],{},"parseXML"," vs ",[19,488,489],{},"parseXml",")",[104,492,493,494,490],{},"Clear (",[19,495,496],{},"parse_xml",[15,498,499,500,503,504,506,507,506,509,512,513,515],{},"The ",[34,501,502],{},"all-caps ambiguity"," in camelCase is worth noting. How do you capitalized an acronym? ",[19,505,485],{},"? ",[19,508,489],{},[19,510,511],{},"parseXmL","? Different teams answer differently. snake_case avoids the question entirely: ",[19,514,496],{},".",[10,517,519],{"id":518},"key-takeaways","Key Takeaways",[287,521,522,525,528,531,534,537],{},[290,523,524],{},"snake_case has a measurable readability edge for unfamiliar code, but familiarity closes the gap.",[290,526,527],{},"Your language ecosystem determines the \"right\" answer more than personal preference.",[290,529,530],{},"The JSON-to-Python mismatch is real — automate conversion at the API boundary.",[290,532,533],{},"Database schemas overwhelmingly use snake_case, regardless of application language.",[290,535,536],{},"In mixed-language stacks, follow each language's convention and convert at boundaries.",[290,538,539],{},"All-caps abbreviations are ambiguous in camelCase; snake_case sidesteps the issue entirely.",[10,541,543],{"id":542},"try-it-yourself","Try It Yourself",[15,545,546],{},"Need to switch between naming styles? Try this tool:",[287,548,549],{},[290,550,551,556],{},[552,553,555],"a",{"href":554},"\u002Ftools\u002Fcase-converter","Case Converter"," — Instantly convert between camelCase, snake_case, PascalCase, and kebab-case",[10,558,560],{"id":559},"related-guides","Related Guides",[287,562,563,570],{},[290,564,565,569],{},[552,566,568],{"href":567},"\u002Fguides\u002Fnaming-conventions-guide","Naming Conventions Guide"," — Full overview of camelCase, PascalCase, snake_case, and kebab-case across languages",[290,571,572,576],{},[552,573,575],{"href":574},"\u002Fguides\u002Fcode-readability-tips","Code Readability Tips"," — Practical techniques for writing code others can understand",[578,579,580],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":197,"searchDepth":211,"depth":211,"links":582},[583,584,585,586,587,588,589,590,591,592,593],{"id":12,"depth":211,"text":13},{"id":29,"depth":211,"text":30},{"id":53,"depth":211,"text":54},{"id":74,"depth":211,"text":75},{"id":186,"depth":211,"text":187},{"id":320,"depth":211,"text":321},{"id":362,"depth":211,"text":363},{"id":404,"depth":211,"text":405},{"id":518,"depth":211,"text":519},{"id":542,"depth":211,"text":543},{"id":559,"depth":211,"text":560},"2026-05-28","Compare camelCase and snake_case — their origins, readability research, language adoption, and when to use each style.","md",{"immutable":598},true,"\u002Fguides\u002Fcamelcase-vs-snake-case",{"title":5,"description":595},"guides\u002Fcamelcase-vs-snake-case","oV34YUUufLY_QzMbMEXI-d0YbHi6-2MJYOyJBAYkXJs",1780401326903]