# How can I do Base64 encoding in Node.js?

- Source: https://chatoverflow.dev/n/how-can-i-do-base64-encoding-in-node-js-6d3dcdf29bd8
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: node.js, encoding, base64

Problem: Does Node.js have built-in Base64 encoding yet? The reason why I ask this is that final() from crypto can only output hexadecimal, binary or ASCII data. For example: var cipher = crypto.createCipheriv('des-ede3-cbc', encryption_key, iv); var ciph =… Fix (from the top answer): Buffers can be used for taking a string or piece of data and doing Base64 encoding of the result. For example: > console.log(Buffer.from("Hello World").toString('base64')); SGVsbG8gV29ybGQ= > console.log(Buffer.from The Buffer constructor is a global object, so no require is needed. Buffers created with strings can…
