Menu

7 Things Wrong With Most Online Case Converters (And What to Use Instead)
πŸ–ΌοΈ

7 Things Wrong With Most Online Case Converters (And What to Use Instead)

DEV CommunityΒ·TechMindΒ·6 months ago
#kTWHBEMg
#flaw#webdev#ai#tooling#word
Reading 0:00
15s threshold

Most free case converter tools share the same 3 fatal flaws. Here is what they are and how to fix them in your own implementation.

Flaw 1: Proper Case β‰  Title Case

Every basic case converter uses CSS text-transform: capitalize logic β€” which capitalizes the first letter of EVERY word. That is Proper Case. True Title Case skips prepositions.

// WRONG β€” capitalizes everything (Proper Case) const properCase = str => str . replace ( / \b\w /g , c => c . toUpperCase ()); // "How To Write A Blog Post For The Web" ❌

// RIGHT β€” true Title Case with small word exceptions const SMALL_WORDS = new Set ([ ' a ' , ' an ' , ' the ' , ' and ' , ' but ' , ' or ' , ' for ' , ' nor ' , ' on ' , ' at ' , ' to ' , ' by ' , ' in ' , ' of ' ]); const titleCase = str => str . toLowerCase (). split ( ' ' ). map (( word , i ) => i === 0 || ! SMALL_WORDS . has ( word ) ? word [ 0 ]. toUpperCase () + word . slice ( 1 ) : word ).…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.