[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › Uint8ArrayFromHex

```ts
const Uint8ArrayFromHex: transform(
  "Uint8ArrayFromHex",
  Hex,
  Uint8Array,
  {
    from: (value) => ok(hexToUint8Array(value)),
    to: uint8ArrayToHex,
  },
);
```

Defined in: [packages/common/src/Type.ts:9012](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/common/src/Type.ts#L9012)

Transforms [Hex](https://evolu.dev/docs/api-reference/common/Type/variables/Hex) text into bytes.

Use it to decode binary fields of JSON and other text payloads, for example
inside an [object](https://evolu.dev/docs/api-reference/common/Type/functions/object). Decoding cannot fail, because Hex accepts only
lowercase digits of whole bytes. Encoding returns lowercase text, so equal
bytes encode to equal strings.

### Example

```ts
import {
  assertEqual,
  assertErr,
  assertOk,
  Uint8ArrayFromHex,
} from "@evolu/common";

const bytes = Uint8ArrayFromHex.fromUnknown("000102ff");
assertOk(bytes, new Uint8Array([0, 1, 2, 255]));
assertEqual(Uint8ArrayFromHex.to(bytes.value), "000102ff");

assertErr(Uint8ArrayFromHex.fromUnknown("000102FF"), {
  type: "Hex",
  value: "000102FF",
});
```