Example 1 — Basic Decode
Decode a Base64 string produced by btoa.
const encoded = btoa("Hello, world");
const decoded = atob(encoded);
console.log(decoded); // Hello, world How It Works
- Encode first.
btoamakes valid Base64. - Call
atob. Pass that Base64 string. - Read the result. ASCII text comes back readable.
- Tip. Same as
window.atob(...)in browsers.

