Online Base64 Encode Decode
1. btoa(): The
btoa() function is used to encode a string to Base64 format.
const encodedString = btoa('Hello, World!');
In the example above, the
btoa() function encodes the string
'Hello, World!' to Base64 format. The result is stored in the
encodedString variable, and it is printed to the console.
2. atob(): The
atob() function is used to decode a Base64-encoded string back to its original form.
const decodedString = atob('SGVsbG8sIFdvcmxkIQ==');
In this example, the
atob() function decodes the Base64-encoded string
'SGVsbG8sIFdvcmxkIQ==' back to its original form. The result is stored in the
decodedString variable and printed to the console.
if (typeof btoa === 'function' && typeof atob === 'function')
For more information on
btoa(), you can refer to the Mozilla Developer Network (MDN) documentation: