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

# Blobs.from

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

Transforms arbitrary data to [`Blobs.Blobs`](/docs/utilities/blobs/types#blobs).

## Imports

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

## Examples

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

const blobs = Blobs.from('0xdeadbeef')
```

### Creating Blobs from a String

An example of creating Blobs from a string using [`Hex.from`](/docs/utilities/hex/from):

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

const blobs = Blobs.from(Hex.fromString('Hello world!'))
```

### Configuring Return Type

It is possible to configure the return type for the Blobs with the `as` option.

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

const blobs = Blobs.from('0xdeadbeef', { as: 'Bytes' })
//    ^?
```

## Definition

```ts
function from<data, as>(
  data: data | Hex.Hex | Bytes.Bytes,
  options?: from.Options<as>,
): from.ReturnType<as>
```

## Parameters

### data

* **Type:** `data | Hex.Hex | Bytes.Bytes`

The data to convert to [`Blobs.Blobs`](/docs/utilities/blobs/types#blobs).

### options

* **Type:** `from.Options<as>`
* **Optional**

Options.

#### options.as

* **Type:** `"Bytes" | "Hex" | as`
* **Optional**

Return type.

## Return Type

The [`Blobs.Blobs`](/docs/utilities/blobs/types#blobs).

`from.ReturnType<as>`
