Core answer: per RFC 4180, a CSV field containing a comma, double quote or newline must be wrapped in double quotes (inner quotes doubled); the universal naming-case algorithm is "split into words, then rebuild"; a URL slug is lowercase words joined by hyphens with accents removed via NFKD.
CSV↔JSON conversion rules
Three core RFC 4180 rules: ① a field with a comma gets wrapped in quotes — "Boston, MA"; ② a field with a double quote doubles it — "He said ""hi"""; ③ a field with a newline keeps it inside quotes.
| Raw CSV | JSON result |
|---|---|
| name,age + Ada,28 | [{"name":"Ada","age":"28"}] |
| "Boston, MA" | One field: Boston, MA |
| "He said ""hi""" | One field: He said "hi" |
Every CSV value is a string by default — 28 arrives as "28"; parse it yourself if you need a number.
Nine naming styles compared
Using "user login count":
| Style | Output | Typical use |
|---|---|---|
| camelCase | userLoginCount | JS/Java variables |
| PascalCase | UserLoginCount | Classes, components |
| snake_case | user_login_count | Python, DB columns |
| SCREAMING_SNAKE | USER_LOGIN_COUNT | Constants, env vars |
| kebab-case | user-login-count | URLs, CSS classes |
| dot.case | user.login.count | Config keys |
| flatcase | userlogincount | Go package-private |
| Title Case | User Login Count | Headlines |
| Train-Case | User-Login-Count | HTTP headers |
The algorithm: split into a word array first (camelCase on case boundaries, snake/kebab on separators), then rebuild with the target rules.
URL slug best practices
- All lowercase —
/Best-Practicesand/best-practicescan be two different URLs - Hyphens between words — Google treats
-as a separator,_glues words - Strip accents — café → cafe (NFKD normalization drops combining marks)
- Drop stop words — shorter slugs win
Non-English titles can stay native (modern stacks support it) or be transliterated. The [slug generator](/c/dev/slugify) offers a keep-CJK mode.
Example: CSV with commas and newlines
```
name,address,note
"Li Si","Chaoyang, Beijing","line one
line two"
```
becomes [{"name":"Li Si","address":"Chaoyang, Beijing","note":"line one\nline two"}] — the comma and newline survive inside quoted fields. The [CSV↔JSON converter](/c/dev/csv-json) also warns on inconsistent column counts.
Example: slug from an article title
"Frontend Trends 2024: React, Vue & Svelte!" → lowercase → strip punctuation → drop stop words → hyphens: frontend-trends-2024-react-vue-svelte. Apostrophes are removed, not hyphenated ("what’s" → "whats").
Common mistakes
- Parsing CSV with split(","): it shatters on the first embedded comma. Use a state machine or a real parser.
- Single quotes or trailing commas in JSON: JSON is double-quote only, no trailing commas, no comments — pasting from a JS object always breaks.
- Keyword-stuffed slugs:
best-cheap-top-2024-reviewreads as spam; 3-5 real words is ideal. - Splitting acronym runs wrong: XMLHttpRequest should become xml_http_request, not x_m_l_http_request — treat consecutive capitals as one word.