[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) › Base64

```ts
const Base64: brand(
  "Base64",
  String,
  (value: string) => {
    const decoded = trySync(() => base64StringToUint8Array(value, "base64"));

    return decoded.ok &&
      uint8ArrayToBase64String(decoded.value, "base64") === value
      ? ok()
      : err<Base64Error>({ type: "Base64", value });
  },
  formatBase64Error,
);
```

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

Base64 text with padding, as defined by [RFC 4648 section
4](https://www.rfc-editor.org/rfc/rfc4648#section-4).

Accepts only the canonical encoding of some bytes: the standard alphabet with
`+` and `/`, the required `=` padding, and unused trailing bits set to zero.
Whitespace, line breaks, and the URL-safe `-` and `_` are rejected. Use
[Base64Url](https://evolu.dev/docs/api-reference/common/Type/variables/Base64Url) for text in URLs and file names.

Every 4 characters encode up to 3 bytes, so the length of padded text does
not determine the byte length: `length(44)(Base64)` accepts 31 to 33 bytes.

Convert bytes to Base64 with [uint8ArrayToBase64](https://evolu.dev/docs/api-reference/common/Type/functions/uint8ArrayToBase64) and convert Base64 to
bytes with [base64ToUint8Array](https://evolu.dev/docs/api-reference/common/Type/functions/base64ToUint8Array).

### Example

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

assertOk(Base64.fromUnknown("AAEC/w=="), "AAEC/w==");
assertErr(Base64.fromUnknown("AAEC/w"));
assertErr(Base64.fromUnknown("AAEC_w=="));
assertErr(Base64.fromUnknown("AB=="));
```