As of ES2023 (ECMAScript 2023), there are no native Base64 encoding or decoding functions added directly to the JavaScript language standard (DataView, ArrayBuffer, etc.).
What’s Available in ES2023:
- There are new features in ES2023 like:
Array.prototype.findLast()
Array.prototype.findLastIndex()
- Hashbang grammar support
- Symbols as WeakMap keys (already allowed)
- Changes to error objects, regex match indices, etc.
But no built-in Base64 methods like btoa() or atob() have been standardized for modern use with typed arrays or strings beyond the browser-specific ones.
Current Browser/Runtime Methods:
In web browsers, you still rely on:
✅ btoa() and atob() — legacy but widely supported
const str = "Hello, world!";
const base64 = btoa(str); // encode
const decoded = atob(base64); // decode
⚠️ Limitations:
- Only works with ASCII/latin-1 strings
- Does not handle Unicode (e.g., emoji or UTF-8 properly) without pre-processing (like
encodeURIComponent)
✅ TextEncoder / TextDecoder + custom Base64 encoder
For full UTF-8 support and binary data, developers often combine these with libraries or utilities:
function utf8ToB64(str) {
const encoder = new TextEncoder();
const bytes = encoder.encode(str);
const binStr = String.fromCodePoint(...bytes);
return btoa(binStr);
}
function b64ToUtf8(b64) {
const binStr = atob(b64);
const bytes = Uint8Array.from(binStr, c => c.codePointAt(0));
return new TextDecoder().decode(bytes);
}
console.log(utf8ToB64("Hello 🌍")); // Base64 encoded string
console.log(b64ToUtf8("SGVsbG8g8J2VlA==")); // Hello 🌍
Libraries or Utilities
If you're working outside the browser (e.g., Node.js), you might use:
- In Node.js:
Buffer.from(data).toString('base64') and Buffer.from(base64str, 'base64')
- Or utility libraries like
base64-js for consistent behavior across platforms
Summary
| Feature | Native in ES2023? |
|---|
Base64 encoding (btoa) | ❌ Not part of ECMAScript spec; browser-only |
Base64 decoding (atob) | ❌ Same as above |
| Modern Base64 APIs | ❌ No |
UTF-8 handling via TextEncoder | ✅ Yes |
So: No, ES2023 does not include native Base64 functions. You still need to use browser-provided methods (btoa/atob) or libraries for robust encoding/decoding.