Random Name and Slug Generator

4.1.0 · active · verified Thu Apr 09

coolname is a Python library for generating random, human-readable names and slugs. It offers various functionalities, including generating names as sequences of words, creating slugs for use in web applications like Django, and generating names of specific lengths. The current version is 4.1.0, and it maintains an active development and release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic usage of `generate_slug` for creating slugs (with default and specified lengths), `generate` for creating word lists, and an example of advanced customization using `RandomGenerator`.

from coolname import generate_slug, generate, RandomGenerator

# Generate a random slug (default length, often 4 words)
print(f"Random slug: {generate_slug()}")

# Generate a slug with a specific number of words
print(f"2-word slug: {generate_slug(2)}")
print(f"3-word slug: {generate_slug(3)}")

# Generate a name as a list of words
name_words = generate()
print(f"Random name (list): {name_words}")
print(f"Joined name: {' '.join(name_words)}")

# Example of custom generator with custom word lists
custom_generator = RandomGenerator({
    'all': {
        'type': 'cartesian',
        'lists': ['adjectives', 'animals']
    },
    'adjectives': {
        'type': 'words',
        'words': ['quick', 'sleepy', 'bright']
    },
    'animals': {
        'type': 'words',
        'words': ['fox', 'panda', 'owl']
    }
})
print(f"Custom generated slug: {custom_generator.generate_slug()}")

view raw JSON →