Skip to content

Poop Code

  • Home
  • Linux

Convert a String to a Blob object in JavaScript

October 21, 2024 by poopcode

To convert a string to a blob in JavaScript we are going to pass the string to a Blob constructor and return the string.

const str2blob = txt => new Blob([txt]);

console.log(str2blob("Poopcode"))

//Blob {size: 8, type: ""}
//size: 8
//type: ""
//__proto__: Blob
Categories Javascript
Save server certificate to your local machine using bash
How To Install Threading Module In Python With Code Examples
© 2025 Poop Code • Built with GeneratePress