HTMLCanvasElement: toDataURL() method - Web APIs | MDN

The HTMLCanvasElement.toDataURL() method returns a data URL containing a representation of the image in the format specified by the type parameter.