Skip to main content
@spa-tools/utilities

bytesToBase64()

The bytesToBase64() function converts a Uint8Array into its equivalent base64 string.

Usage

import { bytesToBase64 } from '@spa-tools/utilities';

const byteArray = new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);
const base64 = bytesToBase64(byteArray);
console.log(base64);
// --> "SGVsbG8gd29ybGQ="

Arguments

NameTypeDescription
bytesUint8ArrayThe byte array to convert

Returns

Returns a base64 string.