DEV Community

Cover image for 7 Things Wrong With Most Online Case Converters (And What to Use Instead)
TechMind
TechMind

Posted on • Originally published at techmind.click

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

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
  ).join(' ');
// "How to Write a Blog Post for the Web" ✅
Enter fullscreen mode Exit fullscreen mode

Flaw 2: Sentence Case Destroys Proper Nouns

// WRONG — basic regex approach
const sentenceCaseBasic = str =>
  str.toLowerCase().replace(/(^\s*\w|[.!?]\s*\w)/g, c => c.toUpperCase());
// "steve jobs founded apple" — all proper nouns gone ❌

// BETTER — preserve already-capitalized words
const sentenceCaseSmart = str => {
  const words = str.split(' ');
  return words.map((word, i) => {
    if (i === 0) return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
    // Preserve words that were intentionally capitalized (proper nouns)
    if (word === word.toUpperCase() && word.length > 1) return word; // abbreviations
    if (/^[A-Z]/.test(word) && i > 0) return word; // already capitalized
    return word.toLowerCase();
  }).join(' ');
};
Enter fullscreen mode Exit fullscreen mode

Flaw 3: No Companion Tools

Every blogger needs: case converter + slug generator + space remover — in the same workflow. Switching between three tools wastes time.

// All three in one utility
const textTools = {
  titleCase: (str) => { /* ... */ },
  sentenceCase: (str) => { /* ... */ },
  slugify: (str) => str.toLowerCase().trim()
    .replace(/[^\w\s-]/g, '')
    .replace(/[\s_]+/g, '-')
    .replace(/--+/g, '-'),
  removeSpaces: (str) => str.replace(/ +/g, ' ').trim()
};

// One input, multiple outputs
const title = "What Is a URL Slug? How to Create SEO-Friendly Slugs!";
console.log(textTools.titleCase(title));
// "What Is a URL Slug? How to Create SEO-Friendly Slugs!"
console.log(textTools.slugify(title));
// "what-is-a-url-slug-how-to-create-seo-friendly-slugs"
Enter fullscreen mode Exit fullscreen mode

For non-technical users, TechMind.click has all of this in one free interface — no code needed.

Top comments (0)