Text Cleanup

Clean Up Slug Input

Prepare a title for conversion into a URL-friendly slug.

Explanation

Slugs should be lowercase, numeric/alphabetic, and use hyphens instead of spaces.

Examples

Article Title
Input
How to Clean Text! (2024)
Output
how-to-clean-text-2024

Code Examples

JavaScript
const slug = input.toLowerCase()
  .replace(/[^a-z0-9]+/g, '-')
  .replace(/^-+|-+$/g, '');

Try it Now

💡 Tips

  • Remove stop words (the, and, a) for shorter URLs
  • Limit length to avoid extremely long URLs
  • Keep it readable for better SEO

⚠️ Common Pitfalls

  • Don't lose the main meaning when stripping characters