# Bytes.toHex

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

## Imports

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

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

## Examples

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

Bytes.toHex(
  Bytes.from([
    72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33
  ])
)
// '0x48656c6c6f20576f726c6421'
```

## Definition

```ts
function toHex(
  value: Bytes,
  options?: toHex.Options,
): Hex.Hex
```

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

## Parameters

### value

* **Type:** `Bytes`

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

### options

* **Type:** `toHex.Options`
* **Optional**

Options.

#### options.size

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

Size of the bytes.

## Return Type

Decoded [`Hex.Hex`](/api/Hex/types#hex) value.

`Hex.Hex`
