---
url: /api/plugins/pantoken/custom-theme-colors/src/functions/parseHexColor.md
---
[pantoken-root](../../../../../index.md) / [plugins/pantoken/custom-theme-colors/src](../index.md) / parseHexColor

# Function: parseHexColor()

> **parseHexColor**(`input`): `string`

Beta

Validate and normalize a user-supplied hex color. This is the only entry point for untrusted
input into generated CSS, so anything but `#rgb`/`#rrggbb` is rejected.

## Parameters

### input

`string`

A hex color, with or without the leading `#`.

## Returns

`string`

Lowercase `#rrggbb`.

## Throws

TypeError when `input` isn't a 3- or 6-digit hex color.
