> **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.toString

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

Decodes a [`Hex.Hex`](/docs/utilities/hex/types#hex) value into a string.

## Imports

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

## Examples

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

Hex.toString('0x48656c6c6f20576f726c6421')
// @log: 'Hello world!'

Hex.toString(
  '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000',
  {
    size: 32
  }
)
// @log: 'Hello world'
```

## Definition

```ts
function toString(
  hex: Hex,
  options?: toString.Options,
): string
```

## Parameters

### hex

* **Type:** `Hex`

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

### options

* **Type:** `toString.Options`
* **Optional**

Options.

#### options.size

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

Size (in bytes) of the hex value.

## Return Type

The decoded string.

`string`
