JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="code" placeholder="b64-encoded image goes here!"></textarea>
<select id="format">
    <option value="png">PNG</option>
    <option value="jpeg">JPEG</option>
    <option value="gif">GIF</option>
</select>
<button id="button">Decode and View</button>
<img id="image">

CSS

textarea, button, img { display: block; }

JavaScript

function doStuff() {
    var img = document.getElementById("image");
    var code = document.getElementById("code");
    var picker = document.getElementById("format");
    
    img.src = "data:image/" + format.value + ";base64," + code.value
}

document.getElementById("button").addEventListener("click", doStuff);