A tiny command line utility that converts colors from one format to another.
cast "#ff0000" --to-hsl # -> hsl(0, 100%, 50%)
cast "oklch(1.000 0.000 0)" --to-rgb # -> rgb(255, 255, 255)
cast "rgba(0, 0, 255, 0.7)" --to-oklch # -> oklch(45.201% 0.31321 264.05 / 0.7)
cast "hsb(208 50% 100%)" --to-hsl # -> hsl(208, 50%, 75%)bunx @hnsn/cast "<color>" [--to-rgb | --to-hsl | --to-hsv | --to-hsb | --to-hwb | --to-oklab | --to-oklch]Or with npx:
npx @hnsn/cast "<color>" [--to-rgb | --to-hsl | --to-hsv | --to-hsb | --to-hwb | --to-oklab | --to-oklch]bun add -g @hnsn/cast
cast "<color>" [--to-rgb | --to-hsl | --to-hsv | --to-hsb | --to-hwb | --to-oklab | --to-oklch]
npm install -g @hnsn/cast
cast "<color>" [--to-rgb | --to-hsl | --to-hsv | --to-hsb | --to-hwb | --to-oklab | --to-oklch]brew install mybuddymichael/tap/cast
cast "<color>" [--to-rgb | --to-hsl | --to-hsv | --to-hsb | --to-hwb | --to-oklab | --to-oklch]Put something like this in your prompt to help LLMs convert colors:
Use the `cast` command to convert colors from one format to another.
Run `cast --help` for usage and a list of supported formats.Note
If you are using this tool with your LLM, I recommend you install it first (and not use it with bunx or npx) so that you have a known-safe and pristine copy on your device.
Run cast --help for a list of supported formats.
To install dependencies:
bun installTo run:
bun run index.ts <color> <output format>This utilizes color.js to convert colors.