Skip to main content

str2col

Deterministically map any value to a color.

from str2col import Str2Col, str2col

# one-off
str2col("hello")              # "#41eaa0"
str2col("hello", fmt="rgb")   # (65, 234, 160)

# reusable converter with constraints
conv = Str2Col(seed="myapp", hue_range=(180, 300), sat_range=(0.5, 0.8))
conv.to_hex("label A")        # "#..."
conv.to_rgb("label A")        # (R, G, B)
conv.to_hsl("label A")        # (hue, sat, light)
conv.to_ansi_fg("label A")    # "\033[38;2;...m"
conv.to_ansi_bg("label A")    # "\033[48;2;...m"

Supported types: strings, ints, floats, None.

Install

pip install str2col

CLI

str2col hello
str2col hello --format rgb
str2col hello --format ansi_fg --text "hello world"
echo "hello" | str2col

Options:

Flag Default Description
--format / -f hex hex, rgb, rgb_float, hsl, ansi_fg, ansi_bg
--seed none shift the color mapping
--hue-range MIN MAX 0 360 restrict hue (degrees)
--sat-range MIN MAX 0.4 0.9 restrict saturation
--light-range MIN MAX 0.35 0.65 restrict lightness
--text TEXT none print TEXT in the computed color

How it works

The input is coerced to a string and hashed with MD5. Three independent 4-byte chunks of the digest are mapped into the configured HSL ranges, then converted to the requested output format via Python's colorsys module.

Metadata

Release files for str2col 0.1.2

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

Source distribution (sdist)

Source distribution for str2col 0.1.2
File Size Uploaded
str2col-0.1.2.tar.gz 4.5 kB Details

Built distribution (wheel)

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

Total release size: 8.7 kB

Release files / str2col-0.1.2.tar.gz

Download URL str2col-0.1.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7e6a34e7e8581786e761d527a7008491da51327a11c180b3a289f394fda17370
BLAKE2b-256 checksum
How to use checksums
c189cff0967d5af4504019d88879ee54f58ce62b1003fb0043d4448b3c03e698
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 Jul 17, 2026.

Transparency log

Release files / str2col-0.1.2-py3-none-any.whl

Download URL str2col-0.1.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcb93096a742cac368f5520cf12ae89dc06418431609e7e0869554a8facbdfb6
BLAKE2b-256 checksum
How to use checksums
f7f40dbe7f65daa7e0a67efb36dc5dc2bf0de08c377ccde9e6af00c4a8b8c92d
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 Jul 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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