skillfed

titlecase

Python Port of John Gruber's titlecase.pl

titlecase v2.4.1 691.2K downloads/30d#5,326 on PyPI267
Permissive license MIT AGING released

What it is and what it does

Titlecase is a text formatting library that converts strings to title case while intelligently preserving small words (a, an, the, and, or, etc.) in lowercase based on New York Times style conventions. It also attempts to detect and preserve acronyms and abbreviations that are already in all caps. The library provides both a Python API and a command-line tool, making it useful for one-off conversions or integration into larger text-processing pipelines.

The package has no runtime dependencies and supports Python 3.7, 3.8, 3.9, and 3.10. It uses regex-based heuristics to handle edge cases, though it acknowledges limitations with contextual awareness (e.g., distinguishing 'us' the pronoun from 'US' the country) and non-English text. The library is a modern port of John Gruber's original titlecase.pl Perl script, maintained on GitHub with a stable user base.

Use it for:

  • Format user-generated titles or headlines in web applications before display or storage.
  • Batch-process document titles or CSV headers from the command line using the titlecase utility.
  • Normalize book, article, or product names in data pipelines while preserving common acronyms via callback functions.
  • Convert all-caps or mixed-case text to consistent title formatting in content management systems.
  • Implement custom capitalization rules for domain-specific acronyms by providing a callback function.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts text to title case with intelligent handling of small words (a, an, the) based on New York Times style rules, plus a command-line utility for batch processing.

Yes, if you need reliable title-case conversion with sensible English-language defaults and don't require frequent updates. The high install friction (source-only distribution) and aging maintenance status are acceptable trade-offs for a stable, single-purpose utility with no dependencies. Not recommended if you need active bug fixes or compatibility guarantees beyond Python 3.10.

Install

titlecase on PyPI

pip

pip install titlecase

uv

uv add titlecase

poetry

poetry add titlecase

Installing titlecase

Before you install

High install friction due to source-only distribution (no wheels). The package is in aging maintenance status—last release was 2023-09-23, over a year ago—though the repository remains active and the code is marked Production/Stable. Suitable for stable, non-critical text processing tasks where you don't expect frequent updates.

License in practice

MIT license (permissive) means you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions, provided you include the license notice.

Quickstart

pip install titlecase

from titlecase import titlecase
result = titlecase('a thing')
print(result)  # 'A Thing'

# With callback for custom handling:
def abbreviations(word, **kwargs):
    if word.upper() in ('TCP', 'UDP'):
        return word.upper()

result = titlecase('a simple tcp and udp wrapper', callback=abbreviations)
print(result)  # 'A Simple TCP and UDP Wrapper'

Requires Python 3.7 or later. Source distribution only (no wheels), so installation requires a working C compiler and development headers if your environment lacks pre-built packages.

Verify before relying

  • Whether the aging maintenance status poses a risk for Python 3.11+ compatibility or future standard library changes.
  • Performance characteristics on very large texts or in high-throughput scenarios.
  • Whether Unicode handling beyond basic accented characters (e.g., non-Latin scripts) is sufficient for your use case.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.7)
Install friction high — source build required
Runtime dependencies none
Maintenance aging — 1,056 days since the last release
Last repo commit
First released
Downloads 691,206/month — #5,326 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: titlecase-2.4.1.tar.gz

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Text Processing :: Filters

Tags

title case conversiontitlecase formattingsmart capitalizationtext title casingcommand line title casesmall words capitalizationtitle formatting tool
text-formattingcli-toolenglish-language

More Filters packages