# @sr-connect/convert

> ScriptRunner Connect utility library for various data conversions

Latest version **1.3.0** (published 2026-09-23) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @sr-connect/convert
pnpm add @sr-connect/convert
yarn add @sr-connect/convert
bun add @sr-connect/convert
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2026-09-23 |
| First published | 2023-10-09 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Adaptavist |
| Maintainers | eknoll, jsaks, mtapsi, skitson, ssarapov, ratwal, theshumanator, jtrumm |

## Links

- npm: https://www.npmjs.com/package/@sr-connect/convert
- npm.io page: https://npm.io/package/@sr-connect/convert

## Recent versions

- 1.3.0 (latest) — 2026-09-23
- 1.2.0 — 2026-02-16
- 1.1.1 — 2025-06-13
- 1.1.0 — 2024-06-25
- 1.0.0 — 2023-10-09

## README

A utility library for the [ScriptRunner Connect](https://scriptrunnerconnect.com) runtime that provides conversion functions for text, buffers, base64 and form data.

# Usage

Either import individual functions:
```typescript
import { convertTextToBase64 } from '@sr-connect/convert';

export default async function(event: any, context: Context): Promise<void> {
	console.log(convertTextToBase64('HELLO WORLD', 'utf8'));
}
```
or import the entire namespace:
```typescript
import { Convert } from '@sr-connect/convert';

export default async function(event: any, context: Context): Promise<void> {
	console.log(Convert.textToBase64('HELLO WORLD', 'utf8'));
}
```

# Available functions
```typescript
convertBase64ToBuffer(base64: string): Uint8Array;
convertBase64ToText(base64: string, encoding?: TextEncoding): string;
convertBufferToBase64(buffer: ArrayBuffer, fastTransfer?: boolean): string;
convertBufferToText(buffer: ArrayBuffer, encoding?: TextEncoding, fastTransfer?: boolean): string;
convertTextToBase64(text: string, encoding?: TextEncoding): string;
convertTextToBuffer(text: string, encoding?: TextEncoding): Uint8Array;
convertTextToText(text: string, sourceEncoding: TextEncoding, targetEncoding?: TextEncoding): string;
convertArrayBufferToFormDataBuffer(...chunks: FormDataChunk[]): BufferedFormData;
```
Every `encoding` parameter defaults to `utf8`. The same functions are available on the `Convert` namespace without the `convert` prefix, so `convertTextToBase64` is `Convert.textToBase64`.

# Changelog
## 1.3.0
* `Convert.bufferToText` and `Convert.bufferToBase64` now accept `fastTransfer`, matching the standalone `convertBufferToText` and `convertBufferToBase64` functions.
* `TextEncoding` now covers every encoding the runtime accepts, adding `utf-16le` and `base64url`.
* Removed the unused `delimiter` property from the object returned by `convertArrayBufferToFormDataBuffer`. It was never part of the encoded payload.
* `convertArrayBufferToFormDataBuffer` now terminates the payload with a closing boundary, which strict servers require.
* Corrected the documentation of several functions.

## 1.2.0
* Introduced `fastTransfer` mode for `convertBufferToText` and `convertBufferToBase64`. When enabled, the call consumes the buffer you pass in, which makes the conversion faster but leaves the buffer unreadable afterwards.

## 1.1.1
* Internal `package.json` fix, no functional changes were introduced with this update.

## 1.1.0
* Added `convertArrayBufferToFormDataBuffer` (or `Convert.arrayBufferToFormDataBuffer`) which encodes form data into a buffer using less memory and CPU than the `FormData` and `Blob` classes.

---
_Source: https://npm.io/package/@sr-connect/convert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
