If you are reading from a URL with node-fetch in NodeJS, you don't want to get a blob but rather a buffer. You can then easily convert to base64.

const b64 = await fetch(url)
      .then((response) => response.buffer())
      .then((buffer) => {
        const b64 = buffer.toString('base64');
        return b64;
      })
      .catch(console.error);
Answer from Geoffrey Bourne on Stack Overflow
🌐
npm
npmjs.com › package › blob-to-base64
blob-to-base64 - npm
February 26, 2019 - const blobToBase64 = require('blob-to-base64') const button = document.querySelector('.button') button.addEventListener('click', function (event) { const blob = document.querySelector('.input').files[0] blobToBase64(blob, function (error, base64) { if (!error) { document.querySelector('.result').innerHTML = base64 } }) }) Contributions are welcome!
      » npm install blob-to-base64
    
Published: Feb 26, 2019
Version: 1.0.2
🌐
Medium
geekjob.medium.com › convert-blob-to-base64-in-js-e5808fd69961
Convert Blob to Base64 in JS - Fullstack CTO - Medium
March 22, 2023 - const blob2base64 = (blob, mimeType) => { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onloadend = () => { const dataUrlPrefix = `data:${mimeType};base64,`; const base64WithDataUrlPrefix = reader.result; const base64 = base64WithDataUrlPrefix.replace(dataUrlPrefix, ''); resolve(base64); }; reader.onerror = reject; reader.readAsDataURL(blob); }); }; const obj = { hello: 'world' }; const mimeType = 'application/json'; const blob = new Blob([JSON.stringify(obj, null, 2)], { type: mimeType }); blob2base64(blob, mimeType).then(base64 => { console.log(base64); }); // or const base64 = await blob2base64(blob, mimeType); console.log(base64);
🌐
Base64.Guru
base64.guru › home › developers › javascript › examples
Encode Blob to Base64 in JavaScript | Examples | JavaScript | Developers | Base64
Another way to convert Blob to Base64 is to call reader.readAsBinaryString(blob) and use btoa(reader.result) to get the Base64 string.
🌐
GitHub
gist.github.com › n1ru4l › dc99062577b746e0783410b1298ab897
Fetch blob and convert to base64 · GitHub
export const fetchAsBlob = url => fetch(url).then(response => response.blob()); not working in React Native android and Nodejs, working for iOS! any alternative solution · Copy link · Copy Markdown · Worked for me on an Android emulator, many thanks! Copy link · Copy Markdown · Thanks, this was perfect · Sign up for free to join this conversation on GitHub.
🌐
codestudy
codestudy.net › blog › blob-to-base64-in-nodejs-without-filereader
How to Convert Blob to Base64 in Node.js Without FileReader: Using Buffer for Image Conversion — codestudy.net
Converting Blobs to Base64 in Node.js is straightforward with the Buffer class. By following these steps—obtaining a Blob, converting it to an ArrayBuffer, wrapping it in a Buffer, and encoding to Base64—you can handle binary data efficiently ...
🌐
GitHub
gist.github.com › Jonarod › 77d8e3a15c5c1bb55fa9d057d12f95bd
Javascript utility to convert Blob to Base64, ImageData or ObjectUrl back and forth. Tree shakeable and promise based. · GitHub
Javascript utility to convert Blob to Base64, ImageData or ObjectUrl back and forth. Tree shakeable and promise based. - blob_conversions_util.js
🌐
YouTube
youtube.com › watch
How to Convert a Blob to Base64 String in Node.js Without Size Loss - YouTube
Learn how to accurately convert `Blob` to `Base64` and back in Node.js without changing size, ensuring data integrity throughout the process.---This video is...
Published: April 1, 2025
Views: 2
Find elsewhere
🌐
npms
npms.io › search
blob to base64
npms was built to empower the javascript community by providing a better and open sourced search for node modules.
🌐
GitHub
github.com › Azure › azure-storage-node › issues › 618
Get Blob (Image.png) and convert to Base64 String · Issue #618 · Azure/azure-storage-node
September 13, 2019 - Save image to blob storage */ const saveBase64ImageToBlob = (base64String, pictureName) => { let rawdata = base64String; let matches = rawdata.match(/^data:([A-Za-z-+/]+);base64,(.+)$/); let type = matches[1]; let buffer = new Buffer(matches[2], 'base64'); blobService.createBlockBlobFromText(config.blob.containerName, pictureName, buffer, {contentType:type}, (error, result, response) => { (error) ?
Author: Azure
🌐
npm
npmjs.com › search
keywords:blob to base64 - npm search
Convert blobs from and to base64 data url strings. ... smali.kazmi• 1.0.3 • 8 months ago • 0 dependents • MITpublished version 1.0.3, 8 months ago0 dependents licensed under $MIT ... Blob & File implementation in Node.js, originally from node-fetch.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-convert-blob-to-base64-encoding-using-javascript
How to convert blob to base64 encoding using JavaScript ? | GeeksforGeeks
June 24, 2024 - Blobs have specific sizes and file types like regular files and can be handled with Buffers, ideal for binary data storage such as images or files. Using the FileReader API, Blobs can be converted into Base64 encoded strings.
🌐
npm
npmjs.com › package › base64-blob
base64-blob - npm
July 23, 2019 - skip to:contentpackage searchsign ... means that you can apply tree-shaking in you project · A module for interconversion of base64 and blob, wrapped by Promise ·...
      » npm install base64-blob
    
Published: Jul 23, 2019
Version: 1.4.1
🌐
npm
npmjs.com › package › @maruware › blob-to-base64
@maruware/blob-to-base64 - npm
September 2, 2020 - import { blobToBase64 } from '@maruware/blob-to-base64' (async () => { const b64 = await blobToBase64(blob) })()
      » npm install @maruware/blob-to-base64
    
Published: Sep 02, 2020
Version: 0.0.8
Author: maruware
🌐
Node.js
nodejs.org › api › buffer.html
Buffer | Node.js v26.10.0 Documentation
Node.js also supports the following binary-to-text encodings. For binary-to-text encodings, the naming convention is reversed: Converting a Buffer into a string is typically referred to as encoding, and converting a string into a Buffer as decoding. 'base64': Base64 encoding.
🌐
YouTube
youtube.com › watch
Convert Image/Blob to Base64 in JavaScript | Blob to String Made Easy! - YouTube
Want to learn how to convert/encode an image into a Base64 string using JavaScript? In this step-by-step tutorial, we’ll fetch an image, convert it into a Bl...
Published: March 19, 2025