> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Hex.fromBytes

:::info
`Hex.fromBytes` is a re-export of ox's [`Hex.fromBytes`](https://oxlib.sh/api/Hex/fromBytes). Refer to the ox documentation for the full reference.
:::

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

## Imports

```ts
import { Hex } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Bytes, Hex } from 'viem/utils'

Hex.fromBytes(
  Bytes.from([
    72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33
  ])
)
// @log: '0x48656c6c6f20576f726c6421'
```

## Definition

```ts
function fromBytes(
  value: Uint8Array,
  options?: fromBytes.Options,
): Hex
```

## Parameters

### value

* **Type:** `Uint8Array`

The [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) value to encode.

### options

* **Type:** `fromBytes.Options`
* **Optional**

Options.

#### options.size

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

The size (in bytes) of the output hex value.

## Return Type

The encoded [`Hex.Hex`](/docs/utilities/hex/types#hex) value.

`Hex`
