Skip to content

Color Name to RGB API Documentation

Overview

This API converts a CSS color name into its corresponding RGB tuple.
It accepts a JSON body containing a color name and returns the RGB values as a structured JSON response.

Base URL:
https://api.apidatatools.com/color-name-to-rgb-api

Supported Operation:
POST

This tool operates only in Body Mode (synchronous).
It does not support URL or File input modes.


Endpoint (POST)

POST https://api.apidatatools.com/color-name-to-rgb-api


Headers

Header Description Required Example
Content-Type Must be application/json Yes application/json
x-source-type Input source type. Only body is supported for this tool. Optional body
x-api-key Your API key for authentication Yes abcd1234xyz

Accepted File Extensions

This tool does not accept file uploads or remote URLs.
It only accepts JSON input directly in the request body.


Input Example (Body Mode)

{
  "name": "red"
}

Example Request

Synchronous (Body Input)

curl -X POST "https://api.apidatatools.com/color-name-to-rgb-api" \
  -H "Content-Type: application/json" \
  -H "x-source-type: body" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{"name": "red"}'

Example Response

Successful (Body Mode)

{
  "status": "success",
  "request_id": "b7f8e2a1-9c3d-4f2e-bc1a-9c8e7f1a2b3c",
  "preview": "{\n  \"r\": 255,\n  \"g\": 0,\n  \"b\": 0\n}"
}

Error Handling

Possible Errors

Error Code HTTP Status Message Example
INVALID_JSON 400 Input must be valid JSON. {"status":"error","error":"INVALID_JSON","details":{"message":"Input must be valid JSON."}}
MISSING_COLOR_NAME 400 JSON must contain 'name' key. {"status":"error","error":"MISSING_COLOR_NAME","details":{"message":"JSON must contain 'name' key."}}
EMPTY_COLOR_NAME 400 Color name cannot be empty. {"status":"error","error":"EMPTY_COLOR_NAME","details":{"message":"Color name cannot be empty."}}
UNKNOWN_COLOR_NAME 400 Color name not recognized. {"status":"error","error":"UNKNOWN_COLOR_NAME","details":{"message":"Color name 'unknown' is not recognized.","available_colors":"148 standard CSS names"}}
PAYLOAD_TOO_LARGE 413 Request body exceeds size limit. {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit for your plan."}}
UNKNOWN_FUNCTION 404 Unsupported API endpoint. {"status":"error","error":"UNKNOWN_FUNCTION","details":{"message":"Unsupported API endpoint."}}
INTERNAL_ERROR 500 Failed to process your request. {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}}

Async Job Status

Not applicable.
This tool does not support asynchronous operations or remote file processing.


Notes for Developers

  • Input must be a valid JSON object containing the key "name".
  • The color name is case-insensitive and normalized to lowercase before lookup.
  • The API returns RGB values as integers in the range 0–255.
  • The response always includes a unique request_id for tracking.
  • Only synchronous body mode is supported; do not use x-source-type: url or x-source-type: file.
  • The API supports 148 standard CSS color names.