# Color Palette Generator (`mangudai/color-palette-generator`) Actor

Generate color palettes from a hex color, a theme in plain words, or an image URL. Get hex, RGB, HSL, color names, WCAG contrast grades, and copy-paste CSS, SCSS and Tailwind. Fully offline, no API key, no scraping.

- **URL**: https://apify.com/mangudai/color-palette-generator.md
- **Developed by:** [Mangudäi](https://apify.com/mangudai) (community)
- **Categories:** Developer tools, Automation, Open source
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Color Palette Generator: text, image, harmony and WCAG

Turn a single color, a few words, or an image into a full color palette. Every palette comes back with hex, RGB and HSL values, plain-English color names, WCAG contrast grades, and copy-paste code for CSS, SCSS and Tailwind.

It runs fully offline. No third-party color API, no API key, nothing to rate-limit or break. The only time it touches the network is when you hand it an image URL to read colors from.

### What you can feed it

Put one item per line in **Colors, themes, or image URLs**. The Actor detects what each line is:

- A hex color like `#2E86DE` or `2E86DE`. It builds a harmony around that exact color.
- A theme in words like `sunset`, `dark forest`, `corporate`, `cyberpunk neon`. Known themes map to hand-picked bases; anything else gets a stable palette derived from the words, so the same phrase always returns the same colors.
- A public image URL. The Actor pulls the dominant colors and also suggests a harmony built from the main one.

### What you get back

Each palette is one dataset item:

- `colors`: the swatches, each with `hex`, `rgb`, `hsl`, a readable `name`, `luminance`, the `bestTextColor` to place on top, and `wcag` grades against white and black.
- `baseColor`, `scheme`, and `temperature` (warm, cool, or neutral).
- `exports`: ready-to-paste `hexList`, `css` variables, `scss` variables, and a `tailwind` config block.
- `allSchemes`: the hex list for all nine harmony schemes, when you leave that option on.
- For image queries: `proportion` on each color and a `suggestedHarmony`.

### Harmony schemes

Complementary, analogous, triadic, split complementary, tetradic, square, monochromatic, shades, and tints. Leave **Harmony scheme** on Auto and each query gets a fitting one, or force a single scheme for every query.

### Example input

```json
{
  "queries": ["#2E86DE", "sunset", "dark forest", "https://example.com/photo.jpg"],
  "scheme": "auto",
  "includeAllSchemes": true,
  "colorsPerImage": 6
}
````

### Why the contrast grades matter

Picking colors is easy; picking colors people can actually read is the hard part. Each swatch is scored with the WCAG 2.1 contrast formula against both white and black text, graded AAA, AA, AA Large, or Fail, so you know at a glance which colors work for body text and which are decoration only.

### Notes

Color naming is algorithmic (hue, lightness and saturation bands), so it stays consistent and never depends on an outside lookup service. Image reading downsamples the picture and clusters its pixels, which keeps runs fast and cheap.

# Actor input Schema

## `queries` (type: `array`):

One line per palette. Each line can be a hex color (e.g. #2E86DE), a theme in plain words (e.g. sunset, dark forest, corporate), or a public image URL to extract colors from.

## `scheme` (type: `string`):

Color harmony to build around the base color. Auto picks a fitting scheme for each query.

## `includeAllSchemes` (type: `boolean`):

Add an allSchemes object with the hex list for all nine harmony schemes, not just the selected one.

## `colorsPerImage` (type: `integer`):

How many dominant colors to pull from each image URL.

## Actor input object example

```json
{
  "queries": [
    "#2E86DE",
    "sunset",
    "dark forest"
  ],
  "scheme": "auto",
  "includeAllSchemes": true,
  "colorsPerImage": 6
}
```

# Actor output Schema

## `palettes` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "#2E86DE",
        "sunset",
        "dark forest"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mangudai/color-palette-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "queries": [
        "#2E86DE",
        "sunset",
        "dark forest",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("mangudai/color-palette-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "#2E86DE",
    "sunset",
    "dark forest"
  ]
}' |
apify call mangudai/color-palette-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mangudai/color-palette-generator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Color Palette Generator",
        "description": "Generate color palettes from a hex color, a theme in plain words, or an image URL. Get hex, RGB, HSL, color names, WCAG contrast grades, and copy-paste CSS, SCSS and Tailwind. Fully offline, no API key, no scraping.",
        "version": "0.0",
        "x-build-id": "7eLP0oNmIM1JDAH0f"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mangudai~color-palette-generator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mangudai-color-palette-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/mangudai~color-palette-generator/runs": {
            "post": {
                "operationId": "runs-sync-mangudai-color-palette-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/mangudai~color-palette-generator/run-sync": {
            "post": {
                "operationId": "run-sync-mangudai-color-palette-generator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "queries"
                ],
                "properties": {
                    "queries": {
                        "title": "Colors, themes, or image URLs",
                        "type": "array",
                        "description": "One line per palette. Each line can be a hex color (e.g. #2E86DE), a theme in plain words (e.g. sunset, dark forest, corporate), or a public image URL to extract colors from.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "scheme": {
                        "title": "Harmony scheme",
                        "enum": [
                            "auto",
                            "complementary",
                            "analogous",
                            "triadic",
                            "split_complementary",
                            "tetradic",
                            "square",
                            "monochromatic",
                            "shades",
                            "tints"
                        ],
                        "type": "string",
                        "description": "Color harmony to build around the base color. Auto picks a fitting scheme for each query.",
                        "default": "auto"
                    },
                    "includeAllSchemes": {
                        "title": "Include every harmony scheme",
                        "type": "boolean",
                        "description": "Add an allSchemes object with the hex list for all nine harmony schemes, not just the selected one.",
                        "default": true
                    },
                    "colorsPerImage": {
                        "title": "Colors to extract per image",
                        "minimum": 2,
                        "maximum": 10,
                        "type": "integer",
                        "description": "How many dominant colors to pull from each image URL.",
                        "default": 6
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
