Preview:
const dataUri = 'data:image/png;base64,iVBORw0KGg...';

const matches = dataUri.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
const type = matches[1];
const buffer = new Buffer.from(matches[2], 'base64');

fs.writeFileSync('image.png', buffer, { encoding: 'base64' });
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter