DEV Community

Steven Liao
Steven Liao

Posted on

btoa replacement in Node.js

If you're trying to use btoa in Node, you'll notice that it is deprecated. It'll suggest you to use the Buffer class instead.

Here's how you replicate the same functionality using Buffer:

// Deprecated
btoa(string)

// Buffer equivalent
Buffer.from(string).toString('base64')
Enter fullscreen mode Exit fullscreen mode

Discussion (0)