I’m constantly working with base64 encoded PNGs and want to preview them.
My current workflow is to console.log(base64PNG)
to the console, and then copy the image into a website like https://base64.guru/converter/decode/image/png where I can decode + preview the image.
Is there some way (for ex. a Chrome extension) where I can just preview these inside the console?
2
Answers
You can just create an Image object and put the base64 as its src, including the data:image… part like this:
It’s what they call "Data URIs" and here’s the compatibility table for inner peace.
You can display images in the console (chrome) see https://github.com/adriancooney/console.image
I had a quick look through the code and created a simple example (the css padding/height/width etc are not right, but it works)
The following function should help, I couldn’t work out how to stop it repeating the image, so I just added
background-repeat: no-repeat
.Depending on the source of your base64 strings, it should be pretty simple to create a bookmarklet to automate this.