Base64 Encoder/Decoder for JavaScript

Free online base64 encoder/decoder with JavaScript code examples

Working with base64 encoder/decoder in JavaScript? Our free online base64 encoder/decoder helps JavaScript developers format, validate, and process data instantly. Below you will find JavaScript code examples using btoa/atob (built-in) so you can achieve the same result programmatically in your own projects.

Try the Base64 Encoder/Decoder Online

Use our free Base64 Encoder/Decoder directly in your browser — no setup required.

Open Base64 Encoder/Decoder

JavaScript Code Example

// Encode
const encoded = btoa("Hello, World!");
console.log(encoded); // SGVsbG8sIFdvcmxkIQ==

// Decode
const decoded = atob(encoded);
console.log(decoded); // Hello, World!

// Node.js alternative:
// Buffer.from(text).toString('base64')

Quick Setup

Library: btoa/atob (built-in)
// Built-in functions — no installation needed

JavaScript Tips & Best Practices

  • btoa/atob only handle ASCII; use Buffer in Node.js for UTF-8
  • In Node.js: Buffer.from(str).toString('base64')
  • For URL-safe Base64, replace + with - and / with _

Frequently Asked Questions

Base64 Encoder/Decoder in Other Languages

More JavaScript Tools