Skip to main content

Convert bytes to human-readable sizes (KB, MB, KiB, MiB, etc.)

Project description

humanbytes

humanbytes is a simple Python package to convert bytes into human-readable sizes using either decimal (KB, MB, ...) or binary (KiB, MiB, ...) units.

Features

  • Convert bytes to a human-readable string
  • Supports both decimal (powers of 1000) and binary (powers of 1024) units
  • Minimal, dependency-free, and easy to use

Installation

pip install humanbytes

Usage

from humanbytes import humanbytes

print(humanbytes(1536))                # 1.54 KB
print(humanbytes(1536, binary=True))   # 1.50 KiB
print(humanbytes(10**9))               # 1.00 GB
print(humanbytes(2**30, binary=True))  # 1.00 GiB

Parameters

  • num: The number to convert (e.g., bytes)
  • binary: If True, use binary units (KiB, MiB, ...). If False (default), use decimal units (KB, MB, ...)

License

MIT License. See LICENSE for details.

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

humanbytes-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

humanbytes-1.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file humanbytes-1.0.0.tar.gz.

File metadata

  • Download URL: humanbytes-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for humanbytes-1.0.0.tar.gz
Algorithm Hash digest
SHA256 55d4f7dcc9d111b061410faf54a70fc1c37e6387dd77c18fe89c49d13ab7bf1c
MD5 72dbcd5fadf1d5d376c5d275bb63ff04
BLAKE2b-256 b292172806ef1c216c72aaf69e84d4cb0a13e95f44f99dd7815588aa5d4e7869

See more details on using hashes here.

File details

Details for the file humanbytes-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: humanbytes-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for humanbytes-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 279c1c376f40aecaa279b9df7d6ab95bbd14609284d4ba230352840dbfc14995
MD5 6a0da4628c592a8e3a57b11e925c39ad
BLAKE2b-256 be23142a9fe1132c3d8204daf1b6b4799788d1e9e3148f2118bae42d9204717c

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