Compatibility: Node.js version 3+ and all major browsers.
npm install abab
btoa (base64 encode)
const btoa = ;; // 'SGVsbG8sIHdvcmxkIQ=='
atob (base64 decode)
const atob = ;; // 'Hello, world!'
Per the spec,
btoa will accept strings "containing only characters in the range
U+00FF." If passed a string with characters above
btoa will return
atob is passed a string that is not base64-valid, it will also return
null. In both cases when
null is returned, the spec calls for throwing a
DOMException of type
If you want to include just one of the methods to save bytes in your client-side code, you can
require the desired module directly.
const atob = ;const btoa = ;
If you're submitting a PR or deploying to npm, please use the checklists in CONTRIBUTING.md.
btoa stand for
Base64 comes from IETF RFC 4648 (2006).
btoa, the encoder function, stands for binary to ASCII, meaning it converts any binary input into a subset of ASCII (Base64).
atob, the decoder function, converts ASCII (or Base64) to its original binary format.