Skip to main content

Summary

humanreadable is a Python library to convert human-readable values to other units.

PyPI package version https://img.shields.io/pypi/pyversions/humanreadable.svg Supported Python implementations CI status of Linux/macOS/Windows Test coverage

Supported Unites

  • time (days, hours, minutes, seconds, etc.)

  • bits per second

Usage

Convert a human-readable value to another unit

Sample Code:
import humanreadable as hr

print("\n[Examples: humanreadable.Time]")
value = "120 sec"
print(f"'{value}' to msecs -> {hr.Time(value).milliseconds}")
print(f"'{value}' to minutes -> {hr.Time(value).minutes}")

value = "12 min 40 sec"
print(f"'{value}' to seconds -> {hr.Time(value).seconds}")

print("\n[Examples: humanreadable.BitsPerSecond]")
value = "1 Gbps"
print(f"'{value}' to Mbps -> {hr.BitsPerSecond(value).mega_bps}")
print(f"'{value}' to Kbps -> {hr.BitsPerSecond(value).kilo_bps}")
print(f"'{value}' to Kibps -> {hr.BitsPerSecond(value).kibi_bps}")
Output:
[Examples: humanreadable.Time]
'120 sec' to msecs -> 120000.0
'120 sec' to minutes -> 2.0
'12 minutes 40 seconds' to seconds -> 760.0

[Examples: humanreadable.BitsPerSecond]
'1 Gbps' to Mbps -> 1000.0
'1 Gbps' to Kbps -> 1000000.0
'1 Gbps' to Kibps -> 976562.5

Convert a value to a human readable string

Sample Code:
import humanreadable as hr

t = hr.Time("400", default_unit=hr.Time.Unit.SECOND)
print(t.to_humanreadable())
print(t.to_humanreadable(style="short"))
Output:
6 minutes 40 seconds
6m 40s

Set default unit

Unit for an instance is determined by input value. If a valid unit is not found, default_unit will be used for the instance (defaults to None).

Sample Code:
import humanreadable as hr

print(hr.Time("1", default_unit=hr.Time.Unit.SECOND))
Output:
1.0 seconds

Units

Available units for humanreadable.Time

Unit

Available unit specifiers (str)

days

d/day/days

hours

h/hour/hours

minutes

m/min/mins/minute/minutes

seconds

s/sec/secs/second/seconds

milliseconds

ms/msec/msecs/millisecond/milliseconds

microseconds

us/usec/usecs/microsecond/microseconds

Available units for humanreadable.BitsPerSecond

Unit

Available unit specifiers (str)

Kbps

[kK]bps/[kK]bits?(/|\s?per\s?)(s|sec|second)

Kibps

[kK]ibps/[kK]ibits?(/|\s?per\s?)(s|sec|second)

Mbps

[mM]bps/[mM]bits?(/|\s?per\s?)(s|sec|second)

Mibps

[mM]ibps/[mM]ibits?(/|\s?per\s?)(s|sec|second)

Gbps

[gG]bps/[gG]bits?(/|\s?per\s?)(s|sec|second)

Gibps

[gG]ibps/[gG]ibits?(/|\s?per\s?)(s|sec|second)

Tbps

[tT]bps/[tT]bits?(/|\s?per\s?)(s|sec|second)

Tibps

[tT]ibps/[tT]ibits?(/|\s?per\s?)(s|sec|second)

bps

bps/bits?(/|\s?per\s?)(s|sec|second)

Installation

Installation: pip

pip install humanreadable

Installation: apt (for Ubuntu)

sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-humanreadable

Dependencies

Metadata

Release files for humanreadable 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for humanreadable 0.4.3
File Size Uploaded
humanreadable-0.4.3.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for humanreadable 0.4.3
File Interpreter ABI Platform
humanreadable-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.3 kB

Release files / humanreadable-0.4.3.tar.gz

Download URL humanreadable-0.4.3.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ab6ff4738e957ed3dc70d52eb46b761df14f7eed6239e74b7ff3e0a20cb79105
BLAKE2b-256 checksum
How to use checksums
e031c97344c7cd2fa4dbc9519238725ae159863d3f91a14e77d1a7c4697dbc16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 9, 2026.

Transparency log

Release files / humanreadable-0.4.3-py3-none-any.whl

Download URL humanreadable-0.4.3-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
245a6633f662ca8c557d54dc403de119357ef0ac4535dfc76e3299658fec4e52
BLAKE2b-256 checksum
How to use checksums
41a11e5eebb72b55f1cf989d10d52aff56efb5e8b468462399314ba4fa5c21ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page