Window.btoa() is marked Baseline Widely available on MDN (since July 2015). Browser Window API — also available as a global in modern Node.js.
✓ Baseline · Widely available
btoa()
Encode binary strings to Base64 across modern browsers.
99%Core tag support
ChromeYes
Full support
EdgeYes
Full support
FirefoxYes
Full support
SafariYes
Full support
OperaYes
Full support
HTML element100% supported
Bottom line: Safe for Base64 encoding of byte-safe / ASCII data. For Unicode text, convert to UTF-8 bytes first.
Frequently Asked Questions
It creates a Base64-encoded ASCII string from a binary string — each character is treated as one byte (code point 0–255). For plain ASCII text, you get a portable Base64 string.
No. MDN marks Window.btoa() as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
btoa() encodes a binary string to Base64; atob() decodes Base64 back. They are inverse operations for Latin-1 / byte-safe data.
The input contains a character whose code point is greater than 255 (for example many emoji). btoa() only accepts single-byte characters.
No. Base64 is encoding, not encryption. Anyone can decode with atob(). Never use btoa() alone to hide secrets.
Convert to UTF-8 bytes first (for example with TextEncoder), turn those bytes into a binary string, then call btoa(). Or use Uint8Array.prototype.toBase64() where available.