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

# Bytes.from

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

Instantiates a [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) value from a `Uint8Array`, a hex string, or an array of unsigned 8-bit integers.

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

* `Bytes.fromBoolean`

* `Bytes.fromString`

* `Bytes.fromNumber`
:::

## Imports

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

## Examples

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

const data = Bytes.from([255, 124, 5, 4])
// @log: Uint8Array([255, 124, 5, 4])

const data = Bytes.from('0xdeadbeef')
// @log: Uint8Array([222, 173, 190, 239])
```

## Definition

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

## Parameters

### value

* **Type:** `Hex.Hex | Bytes | readonly number[]`

Value to convert.

## Return Type

A [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) instance.

`Bytes`
