# CompactSize.fromBytes

Decodes a CompactSize-encoded value from [`Bytes.Bytes`](/api/Bytes/types#bytes).

## Imports

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

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

## Examples

```ts twoslash
import { CompactSize } from 'ox'

const result = CompactSize.fromBytes(
  new Uint8Array([0xfd, 0x00, 0x01])
)
// { value: 256, size: 3 }
```

## Definition

```ts
function fromBytes(
  data: Bytes.Bytes,
): fromBytes.ReturnType
```

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

## Parameters

### data

* **Type:** `Bytes.Bytes`

The bytes to decode from.

## Return Type

The decoded value and number of bytes consumed.

`fromBytes.ReturnType`
