Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

Base64 Decoding in JavaScript: Browser and Node.js Methods

Learn the right way to decode Base64 in JavaScript: get bytes with browser APIs or Node.js Buffer, then use TextDecoder when the data is UTF-8 text.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To decode Base64 in JavaScript, first choose the runtime and decide whether you need the original bytes or UTF-8 text. In a modern browser, use Uint8Array.fromBase64() for bytes; use TextDecoder afterward if those bytes represent text. In Node.js, use Buffer.from(value, "base64"). The title also mentions a free tool, but no specific tool is identified here, so this guide focuses on code rather than making unsupported claims about an online utility.

What does Base64 decoding return?

Base64 represents binary data using text characters. Decoding it produces bytes—not automatically a JavaScript string of readable Unicode text. To get text, you also need to know the character encoding used for those bytes, commonly UTF-8. MDN explains the distinction between Base64 and text encoding in its Base64 glossary entry.

As an Amazon Associate I earn from qualifying purchases.

This distinction matters for files, images, and other binary data, as well as text containing characters beyond basic ASCII. Keep the decoded bytes as bytes unless you know they represent text and know the encoding.

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.

How do you decode Base64 in a modern browser?

Where supported, Uint8Array.fromBase64() is a direct way to decode a Base64 string into bytes:

const bytes = Uint8Array.fromBase64(encoded);

The result is a Uint8Array, not text. MDN lists this API as Baseline 2025, but older browser versions may not support it. Check support for the browsers your application targets before relying on it. See the MDN reference for Uint8Array.fromBase64().

Decode Base64URL input

Base64URL uses - and _ instead of standard Base64’s + and /. Tell the API which alphabet the input uses:

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

The method also offers lastChunkHandling options. 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 processing incremental input and you want to stop before an incomplete final chunk. Choose the behavior that matches your input and validation requirements rather than treating every malformed or incomplete value the same way.

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

How do you turn decoded browser bytes into text?

If the bytes are UTF-8 text, decode them with TextDecoder after Base64 decoding:

const bytes = Uint8Array.fromBase64(encoded);
const text = new TextDecoder("utf-8").decode(bytes);

These are two separate operations: Base64 decoding recovers bytes, and TextDecoder interprets those bytes as UTF-8. Do not use this text conversion for arbitrary binary data.

How do you decode Base64 with atob()?

atob() is a browser option when you need broader compatibility with older environments. It returns a binary string: each character’s code unit represents one byte. Convert that string to a byte array before treating the result as UTF-8 text:

function base64ToBytes(base64) {
  const binary = atob(base64);
  return Uint8Array.from(binary, (character) => character.charCodeAt(0));
}

const bytes = base64ToBytes(encoded);
const text = new TextDecoder("utf-8").decode(bytes);

Calling atob(encoded) alone does not decode arbitrary Unicode text. Invalid Base64 can cause atob() to throw an InvalidCharacterError. MDN documents the return value and error behavior in its atob() reference and shows the byte-first approach in its Base64 encoding and decoding guide.

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

How do you decode Base64 in Node.js?

In Node.js, use Buffer.from() to create a buffer containing the decoded bytes. Convert the buffer to a string only when you know the bytes represent text, and specify the appropriate encoding:

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

Node documents Buffer.from(str, 'base64') as the way to convert a Base64 string to binary data. Its buffer.atob() is a legacy compatibility function; use the Buffer API for Node.js code. 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

Which method should you choose?

Where the code runs Starting point What you get Key consideration
Modern browser Uint8Array.fromBase64() Uint8Array bytes Check target-browser support; set alphabet: "base64url" for URL-safe input.
Browser needing wider legacy compatibility atob(), then convert the binary string to a Uint8Array A binary string first, then bytes The binary string is not decoded Unicode text; use TextDecoder if the bytes are UTF-8 text.
Node.js Buffer.from(value, "base64") Buffer bytes Choose an explicit text encoding only if the bytes represent text.

Why can Base64 examples fail with accented letters or emoji?

btoa() and atob() operate on binary strings, not arbitrary Unicode strings. MDN notes that btoa() throws when a character’s code point exceeds 0xff. An ASCII-only example may appear to work while failing for accented characters, emoji, or other non-ASCII text.

For Unicode text, encode the text to bytes with TextEncoder before Base64-encoding those bytes; when decoding, reverse the sequence by turning the Base64 result into bytes and then using TextDecoder. This preserves the separation between text encoding and Base64 representation described in MDN’s Base64 guide.

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

Does decoding Base64 make the data secret?

No. Base64 is an encoding, not encryption. Decoding reverses the representation; it does not reveal a protected secret or make data confidential. Do not treat Base64-encoded values as secure merely because they are not immediately readable.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.