# uint8-to-base64

> A safe Uint8Array to base64 string converter

Latest version **0.2.1** (published 2025-06-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install uint8-to-base64
pnpm add uint8-to-base64
yarn add uint8-to-base64
bun add uint8-to-base64
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2025-06-23 |
| First published | 2020-02-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | Uint8Array, base64, conversion, safe, encode, decode |

## Links

- npm: https://www.npmjs.com/package/uint8-to-base64
- Repository: https://github.com/WebReflection/uint8-to-base64
- Homepage: https://github.com/WebReflection/uint8-to-base64#readme
- Issues: https://github.com/WebReflection/uint8-to-base64/issues
- npm.io page: https://npm.io/package/uint8-to-base64

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2025-06-23
- 0.2.0 — 2020-02-19
- 0.1.1 — 2020-02-18
- 0.1.0 — 2020-02-18
- 0.0.0 — 2020-02-18

## README

# A safe Uint8Array to base64 string converter

[![Build Status](https://travis-ci.com/WebReflection/uint8-to-base64.svg?branch=master)](https://travis-ci.com/WebReflection/uint8-to-base64) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/uint8-to-base64/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/uint8-to-base64?branch=master)

<sup>**Social Media Photo by [Suzanne D. Williams](https://unsplash.com/@scw1217) on [Unsplash](https://unsplash.com/)**</sup>

Compatible with any binary data and every modern JS engine.

```js
import {encode, decode} from 'uint8-to-base64';
// const {encode, decode} = require('uint8-to-base64');

const utf8Binary = new Uint8Array(anyArrayBuffer);

// encode converts Uint8Array instances to base64 strings
const encoded = encode(utf8Binary);

// it's just like any other string
console.log(encoded);

// decode converts base64 strings, encoded via this module,
// into their original Uint8Array representation
const decoded = decode(encoded);

console.assert(
  JSON.stringify([...utf8Binary]) ===
  JSON.stringify([...decoded]),
  'safe Uint8Array to utf-16 conversion'
);
```

**Please note** this module requires global `atob` and `btoa` in NodeJS **< 16**, polyfilled in old tests in here as such.

```js
global.btoa = str => Buffer.from(str).toString('base64');
global.atob = str => Buffer.from(str, 'base64').toString();
```

Looking for a drop in module that converts into utf-16 strings instead? Check [uint8-to-utf16](https://github.com/WebReflection/uint8-to-utf16#readme) out!

---
_Source: https://npm.io/package/uint8-to-base64 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
