> For the complete documentation index, see [llms.txt](https://docs.sacruda.nl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sacruda.nl/developers/sacruda-apis/data-conversion.md).

# Data conversion

Helper functions for converting data

Sacruda has several utilities built-in for converting data to different formats. All of these helper functions are part of the `convert` object. Here's what you get:

```typescript
export function arrayToText(buffer: ArrayLike<number> | ArrayBufferLike): string;
```

Converts an `ArrayBuffer` to a `string`.

***

```typescript
export function textToArrayBuffer(text: string): ArrayBuffer;
```

Converts a `string` to an `ArrayBuffer`.

***

```typescript
export function blobToText(blob: Blob): Promise<string>;
```

{% hint style="info" %}
This function is asynchronous; it should be awaited.
{% endhint %}

Asynchronously converts a `Blob` to a `string`.

***

```typescript
export function textToBlob(text: string, type?: string): Blob;
```

Converts a `string` to a `Blob`, optionally specifying a mimetype.

***

```typescript
export function arrayToBlob(buffer: ArrayBuffer, type?: string): Blob;
```

Converts an `ArrayBuffer` to a `string`, optionally specifying a mimetype.

***

```typescript
export function blobToDataURL(blob: Blob): Promise<string | undefined>;
```

{% hint style="info" %}
This function is asynchronous; it should be awaited.
{% endhint %}

Converts a `Blob` to a Data URL

***

Ofcourse you have all the flexibility you need to convert data your own way, these are just the functions that I've written for Sacruda to make data conversion with especially filesystem operations easier.
