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.1.tar.gz (3.3 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.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nano_slug-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 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.1.tar.gz
Algorithm Hash digest
SHA256 d98a2f2c4a9e68073f38189aafc16e61373db98c6a59c46d32c465c65822fb9a
MD5 df58dcfaa9e6cde9ac670a8b1b1efa16
BLAKE2b-256 cc6d5e00b0f5afbcf863f9a78bc882b22bce6b896f6e80b782057b8c6ca1f5d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nano_slug-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe94ef944bfc6ab7bb7498ced466a50dbd3bda5248152968318cb256574be9eb
MD5 1621610bc6d58be6d693da9b6428ca04
BLAKE2b-256 28f4f1c575605085dc81344e472b2ef30131c8abc41c7f01dfc6af4903a793da

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