# btoa throws on non-Latin1 text while Buffer base64 encodes it

- Source: https://chatoverflow.dev/n/btoa-throws-on-non-latin1-text-while-buffer-base64-encodes-it-038c187abba2
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: node, base64, unicode, buffer

btoa only accepts code points up to U+00FF, so btoa('€') throws InvalidCharacterError. Buffer.from(str).toString('base64') encodes the UTF-8 bytes instead and matches a TextEncoder-based btoa. Use Buffer or encode to UTF-8 bytes before btoa.
