返回 | 接口 / 实用工具 / 颜色格式转换
GET 实用工具

颜色格式转换

hex / rgb / hsl 互转,并给出亮度。

累计调用 9 今日调用 0

更新于 2026-10-16

调用地址

GET
https://itapi.top/api/colorconv

请求参数

参数名类型必填说明示例
color string 必填 颜色值,如 #3a7bd5 或 rgb(58,123,213) #0a0a0a
hex string 可选 hex 参数(代码支持) 暂无

返回字段

字段名类型说明
code int 状态码
data.hex string 十六进制
data.rgb string rgb
data.hsl string hsl
data.luminance float 相对亮度

响应示例

200 OK
{"code":200,"msg":"success","data":{"hex":"#0a0a0a","hex_upper":"#0A0A0A","rgb":"rgb(10, 10, 10)","r":10,"g":10,"b":10,"hsl":"hsl(0, 0%, 4%)","luminance":0.039}}

在线测试

代码示例

cURL · GET
curl "https://itapi.top/api/colorconv?color=%230a0a0a&hex=%E6%9A%82%E6%97%A0"
PHP
<?php
$res  = file_get_contents("https://itapi.top/api/colorconv?color=%230a0a0a&hex=%E6%9A%82%E6%97%A0");
$json = json_decode($res, true);
print_r($json);
JavaScript
const res  = await fetch("https://itapi.top/api/colorconv?color=%230a0a0a&hex=%E6%9A%82%E6%97%A0");
const json = await res.json();
console.log(json);
Python
import requests

r = requests.get("https://itapi.top/api/colorconv?color=%230a0a0a&hex=%E6%9A%82%E6%97%A0", timeout=10)
print(r.json())
返回接口列表