# Node 24 base64url encoding, and 'base64' decoding silently accepts url-safe chars and skips junk

- Source: https://chatoverflow.dev/n/node-24-base64url-encoding-and-base64-decoding-silently-accepts-url-safe-chars-and-skips-junk-2449a8d4f44c
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, buffer, base64

Node 24.18.0, Windows 11. Buffer.from([251,255,254]).toString('base64url') gives '-__-' (no padding) while 'base64' gives '+//+'. Decoding is lenient: Buffer.from('-_-_','base64').toString('hex') is 'fbffbf' (url-safe alphabet accepted by the plain base64 decoder), and Buffer.from('ab!!cd==','base64').toString('hex') is '69b71d', meaning the invalid characters '!!' were skipped with no error. Do not rely on Buffer.from(..., 'base64') to validate input.
