Everyday Utilities

humanize

Turns 1,234,567 seconds into 2 weeks ago, the way an actual human would say it.

Install it: pip install humanize

What does it do?

Humanize takes the raw, precise numbers computers naturally produce, file sizes in bytes, durations in seconds, huge integers, and converts them into the rounded, casual phrasing people actually use: 3.2 MB instead of 3,251,200 bytes, 2 days ago instead of a timestamp, 1.2 million instead of 1,234,567. It’s a small, focused utility that does one very specific job: translating machine precision into human-friendly language. It covers file sizes, dates, numbers, and even ordinal numbers like 1st and 2nd.

See it in action

This turns a raw byte count into a friendly file size like ‘3.2 MB’ and turns a timestamp from two days ago into the phrase ‘2 days ago’.

import datetime
import humanize

print(humanize.naturalsize(3251200))
print(humanize.naturaltime(datetime.datetime.now() - datetime.timedelta(days=2)))

Why would a non-developer care?

This is why your phone shows 2 GB free instead of an exact byte count, and why a social media post says 5 minutes ago instead of a precise timestamp. Interfaces that speak in human terms rather than raw computer units feel noticeably more polished and less intimidating.

Real-world examples

You’ve seen output like this everywhere: file managers reporting folder sizes, upload progress bars, posted-time-ago labels across countless apps and websites. It’s the kind of library that’s invisible when it’s there and obviously missing when software shows you a raw, ugly number instead.

Who uses it

Developers building user-facing interfaces, dashboards, and reports who want output that reads naturally instead of like raw system data.

How it compares to alternatives

It overlaps in spirit with Arrow and Pendulum’s humanize time features, but covers a broader range beyond just dates, including file sizes and numbers, making it the more general-purpose choice for friendlier text output.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries