How can I console.log() a Blob object?

jkjustjoshing picture jkjustjoshing · Dec 30, 2014 · Viewed 11k times · Source

I have a Blob object I want to inspect by logging its value. All I can see are type and size properties. Is there a way to do this?

console.logging a blob shows this

Answer

epascarello picture epascarello · Dec 30, 2014

Basic example on using a FileReader to look at the content in a blob

var html= ['<a id="anchor">Hello World</a>'];
var myBlob = new Blob(html, { type: 'text/xml'});
var myReader = new FileReader();
myReader.onload = function(event){
    console.log(JSON.stringify(myReader.result));
};
myReader.readAsText(myBlob);