WebToolsPlanet
Converter Tools

Base64 to JavaScript

Decode Base64 strings commonly encountered in JavaScript workflows — API responses, atob() output, Buffer-encoded values, and JWT payload segments. Includes the equivalent JavaScript code snippets for browser and Node.js contexts.

Last updated: May 28, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is Base64 to JavaScript?

JavaScript developers encounter Base64 in many everyday situations: decoding values returned by atob(), reading Buffer-encoded data in Node.js, inspecting JWT payload sections, parsing data URIs, and decoding Basic Auth headers in HTTP clients.

This tool decodes any Base64 string instantly and provides the equivalent JavaScript code — atob() for browsers and Buffer.from() for Node.js — so you know exactly how to reproduce the decode in your own code.

How to Use Base64 to JavaScript

1

Paste the Base64 string into the input field

2

Click "Decode" to recover the original text

3

Enable URL-safe mode if the string uses - and _ instead of + and /

4

Copy the decoded output or use the provided JS code snippet in your project

Common Use Cases

  • Frontend developers decoding Base64 values returned by APIs or stored in localStorage and cookies.
  • Node.js engineers decoding Buffer-encoded strings in data pipelines or file processing scripts.
  • JavaScript developers inspecting the payload section of a JWT token (the middle Base64url segment).
  • Web developers decoding data URIs to inspect the embedded content type and raw data.
  • Security engineers reading Base64-encoded credentials or tokens in captured HTTP traffic.

Example Input and Output

Decoding a Base64-encoded configuration object passed as a URL parameter in a JavaScript application.

Base64 string
eyJlbnYiOiJwcm9kdWN0aW9uIiwiZGVidWciOmZhbHNlfQ==
Decoded text
{"env":"production","debug":false}

Node.js Buffer

In Node.js, use Buffer.from(str, "base64").toString("utf8") rather than atob(), which is only available in browser globals and modern Node.js 16+.

Browser-side only

Decoding runs locally in your browser. Nothing is transmitted.

Frequently Asked Questions

What is the JavaScript equivalent of this decoder?
In browsers: atob(base64String). In Node.js: Buffer.from(base64String, "base64").toString("utf8"). For URL-safe Base64, replace - with + and _ with / before passing to atob().
How do I decode the payload of a JWT in JavaScript?
Copy the middle section of the JWT (between the two dots), replace - with + and _ with /, then pass it to atob(). Or enable URL-safe mode here and paste the segment directly.
What is URL-safe Base64?
URL-safe Base64 uses - instead of + and _ instead of / so the string can appear in URLs without percent-encoding. JWTs use URL-safe Base64 without padding (=).
Is my data sent to a server?
No. All decoding runs in your browser.