Encodes a string into Base64 format.
Automatically handles the environment:
window
Buffer
window.btoa
The input string to encode.
The Base64-encoded representation of the input string.
const encoded = toBase64("Hello World");console.log(encoded); // "SGVsbG8gV29ybGQ=" Copy
const encoded = toBase64("Hello World");console.log(encoded); // "SGVsbG8gV29ybGQ="
Encodes a string into Base64 format.
Automatically handles the environment:
window), usesBuffer.window.btoa.