ForHosting KIT · Developer Utilities

Expand hex color shorthand

The hex color shorthand expander turns a compact three-digit CSS color into its complete six-digit equivalent.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter a value such as #3a7 and receive #33aa77, ready for stylesheets, design tokens, configuration files, or APIs that require the long notation. The tool validates the entire input before expanding it, so six-digit colors, alpha variants, misspelled characters, and incomplete values return a clear error instead of a misleading result. Output is normalized to lowercase and always includes the leading hash for direct use in CSS.

How three-digit hex expansion works

A CSS hexadecimal color normally describes red, green, and blue with two digits per channel. In the shorthand form, each channel uses only one digit. Expansion does not add zeroes or estimate a nearby shade; it repeats every original digit. Therefore #3a7 becomes #33aa77: the red digit 3 becomes 33, the green digit a becomes aa, and the blue digit 7 becomes 77. This repetition preserves the exact color represented by the shorthand under CSS rules. The expander accepts uppercase or lowercase hexadecimal letters and normalizes its answer to lowercase, which makes generated configuration consistent without changing the color. A leading hash is optional on input because shorthand values often arrive from spreadsheets, command-line arguments, or form fields without CSS punctuation. The returned full value always includes the hash, and a second field provides the same six digits without it for systems that store raw hexadecimal text. No color-space conversion or rounding occurs; the operation is a direct, deterministic character transformation.

What counts as valid input

Valid input contains exactly three hexadecimal digits after an optional leading hash. The allowed digits are 0 through 9 and A through F in either letter case. Values such as #09f, abc, and F0C are valid, while #12, #1234, #112233, red, 0xabc, and #ggg are not. This strict rule matters because several similar-looking formats have different meanings. Four digits can represent shorthand with an alpha channel, and six digits are already expanded; silently accepting either would make the capability do something other than its stated job. Surrounding whitespace is trimmed for ordinary form and clipboard use, but spaces inside the color remain invalid. The input must also be a string, since numeric values can lose meaningful leading zeroes before they reach the expander. When validation fails, the API returns an invalid-input error with a message that describes the required three-digit form. This makes mistakes visible in automated workflows and prevents malformed values from being written into a stylesheet or design-token collection.

Using the expanded color in a workflow

Use the expanded value when a downstream tool, schema, or team convention expects six-digit colors. A migration script can normalize old stylesheet tokens before comparing them, a design-system importer can convert compact values before storing canonical tokens, and a validation pipeline can reject accidental names or alpha forms at its boundary. Because the output is stable lowercase text, repeated calls with equivalent letter casing produce the same canonical result, which helps diffs and cache keys remain tidy. The browser runner uses the same pure expansion logic as the API, so a value checked interactively behaves identically when the task is automated. The operation has no network dependency and does not inspect external color databases. Send one shorthand color in the hex field, then read expanded for a CSS-ready value or expanded_no_hash when another format supplies its own prefix. API execution costs $0.002 per request. The result deliberately stays focused on expansion: use a separate color conversion capability if you need RGB channel numbers, HSL values, names, mixing, or contrast analysis.

Normalize design tokens

Convert compact token values to consistent six-digit lowercase colors before storing or comparing them.

Prepare CSS for a strict pipeline

Expand shorthand colors for linters, generators, or schemas that require the full #RRGGBB notation.

Validate imported color data

Reject invalid characters and wrong-length values while converting legitimate three-digit entries from a feed.

What does the expansion do?

It duplicates each shorthand digit. For example, #3a7 becomes #33aa77.

Is the leading hash required?

No. Both #abc and abc are accepted, and the expanded field always includes a leading hash.

Are uppercase letters accepted?

Yes. Hexadecimal letters A through F may be uppercase or lowercase; output is normalized to lowercase.

Can I submit a six-digit or four-digit color?

No. This capability accepts exactly three hex digits. Other lengths return an invalid-input error.

How much does the API request cost?

Each API request costs $0.002. The same deterministic expansion is also available in the browser runner.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/color/hex-shorthand-expand

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/color/hex-shorthand-expand \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"hex":"#3a7"}'
{
  "hex": "#3a7"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "color.hex_shorthand_expand",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →