How can I visualize a base64 image in Postman?

Viewed 54

I have a request that returns a this is my postman output base64 string. Is there a way to visualize the image in Postman?

1 Answers

You can use Postman's visualize feature. I've created a public sample to demonstrate this. To do this, I've set a sample base64 image on the body of the request and using Postman Echo, it just returns the same value on the data field. With that, I just read the data and use a visualizer to present it:

// Image is found on the respose on the data field
const imageBase64 = pm.response.json().data;

// This is just a simple template with a placeholder for a base64 image
var template = `<img src="data:image/svg+xml;base64,{{image}}" />`


// Set visualizer - Inits handle bars and passes the image variable to the template
pm.visualizer.set(template, {
    // Pass the response body parsed as JSON as `data`
    image: imageBase64
});

This will look like the following, if you click the Visualize tab:

enter image description here

Related