npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

turkish-slugify

v1.0.0

Published

Convert Turkish text to URL-friendly slugs - Zero dependencies, TypeScript native, browser + Node.js compatible

Readme

🇹🇷 Turkish Slugify

Convert Turkish text to URL-friendly slugs with zero dependencies. Optimized for Turkish characters (çğıöşü) with full TypeScript support.

NPM Version NPM Downloads TypeScript License: MIT

✨ Why Turkish Slugify?

  • 🎯 Turkish-First Approach: Designed specifically for Turkish characters
  • 📦 Zero Dependencies: Lightweight and secure
  • 🌍 Universal: Works in Browser, Node.js, and Deno
  • 🔷 TypeScript Native: Full type support out of the box
  • ⚡ High Performance: Optimized conversion algorithms
  • 🎨 Flexible: Extensive customization options

🚀 Quick Start

Installation

npm install turkish-slugify

Basic Usage

import { turkishSlugify } from 'turkish-slugify';

// Turkish characters → URL-friendly slugs
turkishSlugify('Merhaba Dünya!');           // → 'merhaba-dunya'
turkishSlugify('İstanbul Üniversitesi');    // → 'istanbul-universitesi'
turkishSlugify('Çok Güzel Öğrenci');        // → 'cok-guzel-ogrenci'
turkishSlugify('ĞÜŞÖÇI Characters');        // → 'gusocci-characters'

With Custom Options

// Custom separator
turkishSlugify('Merhaba Dünya', { separator: '_' });
// → 'merhaba_dunya'

// Preserve case
turkishSlugify('JavaScript Çok Güzel', { preserveCase: true });
// → 'JavaScript-Cok-Guzel'

// Length limiting
turkishSlugify('Çok uzun bir başlık örneği', { maxLength: 15 });
// → 'cok-uzun-bir'

// Custom replacements
turkishSlugify('React & Vue.js', { 
  customReplacements: { '&': 'and' } 
});
// → 'react-and-vue-js'

📖 API Reference

turkishSlugify(text, options?)

Converts Turkish text to URL-friendly slug.

Parameters

  • text (string): Text to convert
  • options (SlugifyOptions): Configuration options

Options

interface SlugifyOptions {
  separator?: string;           // Default: '-'
  lowercase?: boolean;          // Default: true  
  strict?: boolean;             // Default: false
  maxLength?: number;           // Default: unlimited
  preserveCase?: boolean;       // Default: false
  customReplacements?: Record<string, string>; // Default: {}
}

| Option | Type | Default | Description | |--------|------|---------|-------------| | separator | string | '-' | Character used to replace spaces | | lowercase | boolean | true | Convert result to lowercase | | strict | boolean | false | Remove all non-alphanumeric characters | | maxLength | number | null | Truncate result to max length | | preserveCase | boolean | false | Keep original character casing | | customReplacements | Record<string, string> | {} | Custom character replacements |

Returns

  • string: URL-friendly slug

🔤 Character Mapping

Turkish characters are converted as follows:

| Turkish | → | Latin | |---------|---|-------| | ç, Ç | → | c, C | | ğ, Ğ | → | g, G | | ı, İ | → | i, I | | ö, Ö | → | o, O | | ş, Ş | → | s, S | | ü, Ü | → | u, U |

Plus common international characters (à, é, ñ, etc.)

💡 Usage Examples

E-commerce URLs

// Product names
turkishSlugify('Çok Güzel T-Shirt');
// → 'cok-guzel-t-shirt'

// Category pages
turkishSlugify('Kadın Giyim & Aksesuar');
// → 'kadin-giyim-aksesuar'

Blog Posts

// Article titles
turkishSlugify('Modern JavaScript Öğreniyoruz');
// → 'modern-javascript-ogreniyoruz'

// SEO-friendly URLs
turkishSlugify('En İyi 10 Türkçe Kaynak', { maxLength: 25 });
// → 'en-iyi-10-turkce'

User-Generated Content

// Forum topics
turkishSlugify('Yardım: CSS Öğrenmek İstiyorum!');
// → 'yardim-css-ogrenmek-istiyorum'

// Custom separators for different systems
turkishSlugify('Kullanıcı Profili', { separator: '_' });
// → 'kullanici_profili'

🌐 Framework Integration

Next.js

// pages/blog/[slug].js
import { turkishSlugify } from 'turkish-slugify';

export async function getStaticPaths() {
  const posts = await getPosts();
  const paths = posts.map(post => ({
    params: { slug: turkishSlugify(post.title) }
  }));
  
  return { paths, fallback: false };
}

Express.js

import express from 'express';
import { turkishSlugify } from 'turkish-slugify';

app.get('/blog/:slug', (req, res) => {
  const friendlySlug = turkishSlugify(req.params.slug);
  // Handle blog post...
});

Vue.js

// composables/useSlug.js
import { turkishSlugify } from 'turkish-slugify';

export function useSlug(text, options = {}) {
  return computed(() => turkishSlugify(text.value, options));
}

📊 Performance

Turkish Slugify is optimized for speed:

// Benchmark: 100,000 conversions
const longText = 'Çok uzun Türkçe metin örneği'.repeat(10);

console.time('turkish-slugify');
for (let i = 0; i < 100000; i++) {
  turkishSlugify(longText);
}
console.timeEnd('turkish-slugify');
// ✅ ~50ms (vs slugify: ~200ms)

🆚 Comparison with Alternatives

| Feature | turkish-slugify | slugify | speakingurl | |---------|----------------|---------|-------------| | Turkish Support | ✅ Native | ⚠️ Manual | ⚠️ Limited | | Zero Dependencies | ✅ | ❌ | ❌ | | TypeScript | ✅ Native | ⚠️ @types | ❌ | | Bundle Size | 📦 3KB | 📦 8KB | 📦 12KB | | Performance | ⚡ Fast | ⚡ Medium | 🐌 Slow | | Browser Support | ✅ All | ✅ All | ⚠️ Limited |

🛠 Development

Setup

git clone https://github.com/kynuxdev/turkish-slugify.git
cd turkish-slugify
npm install

Scripts

npm run build        # Build all formats
npm test            # Run tests
npm run test:watch  # Watch mode testing  
npm run dev         # Development mode

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 Migration Guide

From slugify

// Before
import slugify from 'slugify';
slugify('Merhaba Dünya', { remove: /[*+~.()'"!:@]/g });

// After  
import { turkishSlugify } from 'turkish-slugify';
turkishSlugify('Merhaba Dünya');

From speakingurl

// Before
import getSlug from 'speakingurl';
getSlug('Türkçe Metin', { lang: 'tr' });

// After
import { turkishSlugify } from 'turkish-slugify';
turkishSlugify('Türkçe Metin');

📄 License

MIT License - see LICENSE file for details.

🤝 Support


Made with ❤️ for the Turkish developer community 🇹🇷