Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

In JavaScript, decode Base64 to bytes first; convert those bytes to text only if they represent text, using the right character encoding such as UTF-8. In a modern browser, use Uint8Array.fromBase64(); in Node.js, use Buffer.from(value, "base64"). The browser’s older atob() API returns a binary string, not automatically decoded Unicode text.

Choose the right JavaScript decoder

The right method depends on where your code runs and what you need back. Base64 represents bytes; it does not specify that those bytes are text. MDN explains the distinction between Base64 and text encoding in its Base64 glossary.

Runtime Starting point Result Key consideration
Modern browser Uint8Array.fromBase64(encoded) Uint8Array bytes Check support in target browsers; choose the URL-safe alphabet option when needed.
Browser with wider legacy compatibility needs atob(encoded), then convert to bytes Binary string first, then bytes The binary string is not Unicode text; use TextDecoder for UTF-8 text.
Node.js Buffer.from(encoded, "base64") Buffer bytes Specify a text encoding only when the decoded bytes represent text.

Decode Base64 to bytes in a browser

Use Uint8Array.fromBase64() in supported browsers

For a modern browser, this API gives you bytes directly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const bytes = Uint8Array.fromBase64(encoded);

MDN marks Uint8Array.fromBase64() Baseline 2025, but older browser versions may not support it. Check your target browsers before relying on it. MDN recommends this method over atob() because a byte array is easier to work with than a string containing raw bytes: Uint8Array.fromBase64().

Handle Base64URL input

Base64URL substitutes - and _ for standard Base64’s + and /. If the input uses that alphabet, select it explicitly:

const bytes = Uint8Array.fromBase64(encoded, { alphabet: "base64url" });

The API also has a lastChunkHandling option. Its default, "loose", accepts certain partial final chunks. "strict" requires a correctly padded final chunk and zero overflow bits. "stop-before-partial" is useful when decoding incremental input and you want to stop before an incomplete final chunk.

Use atob() when you need a compatibility path

atob() is a browser API. It returns a binary string whose character code units represent bytes; it does not turn those bytes into Unicode text. Convert the string to a byte array before further processing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function base64ToBytes(base64) {
  const binary = atob(base64);
  return Uint8Array.from(binary, (character) => character.charCodeAt(0));
}

const bytes = base64ToBytes(encoded);

Invalid Base64 can cause atob() to throw an InvalidCharacterError. See MDN’s atob() reference.

Convert decoded bytes to UTF-8 text

If you know the bytes represent UTF-8 text, decode them as a separate step with TextDecoder. This works with the byte array from either browser approach:

const text = new TextDecoder().decode(bytes);

For the atob() path, you can combine the conversion and text decoding like this:

const text = new TextDecoder().decode(base64ToBytes(encoded));

Base64 decoding and character decoding are separate operations: the first recovers bytes, while the second interprets those bytes as text. MDN demonstrates the byte-first approach in its Unicode discussion of Base64.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decode Base64 in Node.js

In Node.js, use Buffer.from() to get the decoded bytes. Convert them to a string only when the data is text and you know its encoding:

const bytes = Buffer.from(encoded, "base64");
const text = bytes.toString("utf8"); // only when the decoded bytes are UTF-8 text

Node’s documentation recommends Buffer.from(str, 'base64') for Base64 conversion. Node also documents buffer.atob() as a legacy compatibility function, rather than the preferred Node.js approach. See the Node.js Buffer documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Avoid the Unicode trap when encoding, too

btoa() and atob() operate on binary strings, not arbitrary Unicode text. In particular, btoa() throws when a character’s code point is greater than 0xff. ASCII-only examples can hide the problem, but accented characters and emoji expose it. Convert text to bytes with TextEncoder before Base64-encoding it; when decoding, recover bytes and then use TextDecoder. MDN covers this limitation in its btoa() Unicode guidance.

What Base64 decoding does—and does not do

Decoding Base64 reverses an encoding; it does not decrypt data or protect it from being read. Treat encoded content as exposed unless it is protected by a separate security mechanism. Base64 is a representation of bytes, not a confidentiality feature.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

About the free tool in the title

No specific online decoder is identified here, so no tool’s privacy practices, speed, availability, or features can be verified. If you use an online decoder, avoid pasting passwords, access tokens, private keys, or other sensitive data into it. For data you should not disclose to a third party, decode it locally with the browser or Node.js code above.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.