Color Converter for Rust
Free online color converter with Rust code examples
Working with color converter in Rust? Our free online color converter helps Rust developers format, validate, and process data instantly. Below you will find Rust code examples using palette so you can achieve the same result programmatically in your own projects.
Try the Color Converter Online
Use our free Color Converter directly in your browser — no setup required.
Open Color ConverterRust Code Example
use palette::{Srgb, Hsl, IntoColor};
fn main() {
// HEX to RGB
let r = u8::from_str_radix("34", 16).unwrap();
let g = u8::from_str_radix("98", 16).unwrap();
let b = u8::from_str_radix("db", 16).unwrap();
println!("RGB: ({}, {}, {})", r, g, b);
// RGB to HSL
let rgb = Srgb::new(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0);
let hsl: Hsl = rgb.into_color();
println!("HSL: ({:.0}, {:.0}%, {:.0}%)",
hsl.hue.into_positive_degrees(),
hsl.saturation * 100.0,
hsl.lightness * 100.0);
// RGB to HEX
println!("HEX: #{:02x}{:02x}{:02x}", r, g, b);
}Quick Setup
Library: palette
cargo add paletteRust Tips & Best Practices
- palette crate provides comprehensive color space support
- It supports sRGB, HSL, HSV, LAB, LCH, and more
- Use IntoColor trait for seamless conversions