Skip to main content

Tiny text → URL slug converter in ~1KB (zero deps)

Project description

nano-slug

PyPI License Size CI

Tiny text → URL slug converter — ~1 KB, zero deps. Lowercases, strips accents, replaces whitespace/punct with -, collapses dashes. Perfect for code-golf, minimal containers, or just for fun.


✨ Features

  • ✅ Unicode → ASCII (Café au laitcafe-au-lait)
  • ✅ Punctuation/whitespace → -, multi-dash collapse, trim ends
  • ✅ Returns slug if result would be empty
  • ✅ Zero dependencies • single tiny file • CLI included

🚀 Usage

# Local (from repo)
python app_min.py "Hello, World!"                        # hello-world
python app_min.py "Türkçe Çalışma — Şaşırtıcı!"          # turkce-calisma-sasirtici

After installing:

# CLI
pip install nano-slug
nano-slug "Café au lait"                                  # cafe-au-lait
echo "  multiple   spaces  " | nano-slug                  # multiple-spaces

🤓 Why so small?

  • Pure stdlib: unicodedata (NFKD) + tiny re replacements
  • No transliteration tables, no locale deps
  • Single tiny file + tiny CLI: perfect for scripts, containers, CI.

🎉 Fun Ideas

  • Batch rename files
for f in *.md; do mv "$f" "$(nano-slug "${f%.md}").md"; done
  • Make anchors for headings
awk '/^#/{sub(/^#* /,""); cmd="nano-slug \""$0"\""; cmd | getline s; close(cmd); print "- ["$0"]( #"s")"}' README.md
  • Slug from git branch
nano-slug "$(git rev-parse --abbrev-ref HEAD)"

Notes: ASCII-only output by design. Non-Latin scripts may collapse to empty → returns "slug".


📜 License

MIT © 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_slug-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_slug-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file nano_slug-0.1.0.tar.gz.

File metadata

  • Download URL: nano_slug-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nano_slug-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bf76456ff6d4d48c4c9a4a6b608a63a90e3466769d36cb48e73aa839f09737a8
MD5 11b728588033356221e1067b83fe6aec
BLAKE2b-256 fd924f269dc5630d8714421cb40a4e442361ded19406e0aee8a955c7df91ad0d

See more details on using hashes here.

File details

Details for the file nano_slug-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nano_slug-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nano_slug-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70af25286957de123d8ec2af5ec26608e5a64dbb5f7ec7a38f6d184753969b27
MD5 2ee7d7d271e3fe671d22709d5dc5867a
BLAKE2b-256 a005f47653586c8393ff2bf5c4f3bf44b3ff628ac41679b09ba1e12d001f56a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page