Encodes a string to Base64. The string is encoded as UTF-8 first. Works in Node.js and browsers.
Optional
The string to encode.
The Base64 encoded string.
const encoded = toBase64('Hello World'); // 'SGVsbG8gV29ybGQ=' Copy
const encoded = toBase64('Hello World'); // 'SGVsbG8gV29ybGQ='
Encodes a string to Base64. The string is encoded as UTF-8 first. Works in Node.js and browsers.