# Hex.toBytes

Decodes a [`Hex.Hex`](/api/Hex/types#hex) value into a [`Bytes.Bytes`](/api/Bytes/types#bytes).

## Imports

:::code-group
```ts [Named]
import { Hex } from 'ox'
```

```ts [Entrypoint]
import * as Hex from 'ox/Hex'
```
:::

## Examples

```ts twoslash
import { Hex } from 'ox'

const data = Hex.toBytes('0x48656c6c6f20776f726c6421')
// @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
```

## Definition

```ts
function toBytes(
  hex: Hex,
  options?: toBytes.Options,
): Uint8Array
```

**Source:** [src/core/Hex.ts](https://github.com/wevm/ox/blob/main/src/core/Hex.ts#L1003)

## Parameters

### hex

* **Type:** `Hex`

The [`Hex.Hex`](/api/Hex/types#hex) value to decode.

### options

* **Type:** `toBytes.Options`
* **Optional**

Options.

#### options.size

* **Type:** `number`
* **Optional**

Size (in bytes) of the hex value.

## Return Type

The decoded [`Bytes.Bytes`](/api/Bytes/types#bytes).

`Uint8Array`
