# Hex.from

Instantiates a [`Hex.Hex`](/api/Hex/types#hex) value from a hex string or [`Bytes.Bytes`](/api/Bytes/types#bytes) value.

:::tip
To instantiate from a **Boolean**, **String**, or **Number**, use one of the following:

* `Hex.fromBoolean`

* `Hex.fromString`

* `Hex.fromNumber`
:::

## Imports

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

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

## Examples

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

Hex.from('0x48656c6c6f20576f726c6421')
// @log: '0x48656c6c6f20576f726c6421'

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

## Definition

```ts
function from(
  value: Hex | Uint8Array | readonly number[],
): Hex
```

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

## Parameters

### value

* **Type:** `Hex | Uint8Array | readonly number[]`

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

## Return Type

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

`Hex`
