---
title: "Helpers/color"
---
# Helpers/color

### colorToHex()

**colorToHex**(`color`): `string` \| `false`

Defined in: [src/core/helpers/color/color-to-hex.ts:24](https://github.com/xdan/jodit/blob/main/src/core/helpers/color/color-to-hex.ts#L24)

Converts rgba text representation of color in hex

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `color` | `string` | string like rgba(red, green, blue, alpha) or rgb(red, green, blue) |

#### Returns

`string` \| `false`

hex color view, NaN - for transparent color

#### Example

```javascript
var p = document.createElement('p');
p.style.color = '#ffffff';
console.log(p.getAttribute('style')); // color: rgb(255, 255, 255);
console.log(colorTohex(p.style.color)); // #ffffff
```
