Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To convert SVG code to PNG, JPEG, or WebP, render the SVG at a chosen pixel size. In a browser, load the SVG markup into an Image, draw it onto a canvas, then export the canvas with toBlob(). Use PNG for transparency and sharp graphics; use JPEG only when you need a smaller lossy file with a solid background. For repeatable local or batch conversions, use Inkscape, ImageMagick, or rsvg-convert.
What converting SVG code to an image means
SVG is vector markup: it describes shapes, text, fills, and other drawing instructions rather than storing a fixed grid of pixels. To make a PNG, JPEG, or WebP, a renderer paints those instructions into pixels at a specified width and height. That raster output has fixed dimensions; the original SVG remains scalable if you keep the markup or source file.
The right dimensions depend on where the image will be used. A small icon might need only a few hundred pixels across, while a hero graphic or retina display asset needs more. Enlarging a raster image later can soften edges, so decide the target size before export.
Free tools Windows power users keep installed
One-click scans. No signup required.
Prepare the SVG for predictable output
For reliable rendering, put explicit width and height attributes on the root <svg>, and set a viewBox that describes the coordinate area. For example:
#1 Best Overall
- Wacom Intuos Small Graphics Drawing Tablet: Enjoy industry leading tablet performance in superior control and precision with Wacom's EMR, battery free technology that feels like pen on paper
- Works With All Software: Wacom Intuos tablet can be used in any software program to explore new facets of digital creativity; draw, paint, edit photos/videos, create designs, and mark up documents
- What the Professionals Use: Wacom's industry leading pen technology and pen to paper feeling makes it the preferred drawing tablet of professional graphic designers
- Software and Training Included: Only Wacom gives you software with every purchase. Register your Intuos tablet and gain access to some of the best creative software and Wacom's online training
- Wacom is the Global Leader in Drawing Tablet and Displays: For over 40 years in pen display and tablet market, you can trust that Wacom to help you bring your vision, ideas and creativity to life
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="450" viewBox="0 0 800 450">
<rect width="800" height="450" fill="#172554" />
<text x="40" y="90" fill="white" font-size="48">Hello SVG</text>
</svg>
The namespace declaration is important when the markup is loaded as an SVG image. The viewBox maps the drawing’s internal coordinate system to the exported dimensions. If an SVG has a viewBox but no explicit pixel dimensions, browsers and command-line renderers may infer or handle its size differently, so add dimensions when you control the markup.
- PNG: A practical default for logos, diagrams, line art, and images that need transparency.
- JPEG: Lossy and opaque. Use it only when the destination requires JPEG or when a solid-background photographic-style output is suitable.
- WebP: A common browser export option when supported by the target environment; confirm that the application consuming the file accepts it.
Convert an SVG string to PNG or JPEG in a browser
Canvas works well when a web application creates SVG markup and needs to offer an image download without sending the content to a server. The code below creates a PNG download from an SVG string. Change the requested MIME type to JPEG or WebP if supported, and provide a quality value for lossy output.
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="800" height="450" viewBox="0 0 800 450">
<rect width="800" height="450" fill="#172554"/>
<text x="40" y="90" fill="white" font-size="48">Hello SVG</text>
</svg>`;
function downloadSvgAsImage(svgText, filename = "converted.png", type = "image/png", quality) {
const sourceBlob = new Blob([svgText], { type: "image/svg+xml;charset=utf-8" });
const sourceUrl = URL.createObjectURL(sourceBlob);
const img = new Image();
img.onload = () => {
const width = img.naturalWidth || 800;
const height = img.naturalHeight || 450;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
if (!context) {
URL.revokeObjectURL(sourceUrl);
throw new Error("Canvas 2D context is unavailable");
}
// JPEG has no transparency; paint a background before drawing.
if (type === "image/jpeg") {
context.fillStyle = "white";
context.fillRect(0, 0, width, height);
}
context.drawImage(img, 0, 0, width, height);
URL.revokeObjectURL(sourceUrl);
canvas.toBlob((imageBlob) => {
if (!imageBlob) {
throw new Error("The browser could not encode the canvas");
}
const downloadUrl = URL.createObjectURL(imageBlob);
const link = document.createElement("a");
link.href = downloadUrl;
link.download = filename;
link.click();
setTimeout(() => URL.revokeObjectURL(downloadUrl), 1000);
}, type, quality);
};
img.onerror = () => {
URL.revokeObjectURL(sourceUrl);
throw new Error("The SVG could not be loaded as an image");
};
img.src = sourceUrl;
}
downloadSvgAsImage(svg, "converted.png", "image/png");
// For JPEG: downloadSvgAsImage(svg, "converted.jpg", "image/jpeg", 0.9);
toBlob() is preferred for downloadable files because it produces a Blob instead of a large in-memory data URL string. PNG is the required fallback export type if the requested type is unsupported. JPEG and WebP are commonly supported and accept quality parameters; check the resulting Blob type if your application needs to know whether the browser honored a requested format. See MDN’s toBlob() reference for supported behavior.
For a small inline result, use canvas.toDataURL("image/png") or canvas.toDataURL("image/jpeg", 0.9). A data URL is convenient to assign to an image’s src, but it encodes the image as a string and can consume substantial memory for large images. MDN recommends Blob/object-URL handling for larger outputs; see toDataURL().
Choose the output dimensions deliberately
The example uses the SVG’s natural dimensions, falling back to 800 by 450. To export at another size, assign the desired pixel width and height to canvas.width and canvas.height, then draw with those dimensions. If you need to preserve the aspect ratio, derive one dimension from the SVG’s width-to-height ratio instead of stretching it. The browser Canvas API paints the source into the target rectangle; MDN’s drawImage() documentation describes its sizing arguments.
Rank #2
- PLEASE NOTE:XPPen Artist13.3 Pro drawing tablet Need to connect with computer,you need to use it with your computer or laptop, the 3 in 1 cable is included
- Drawing Tablet with Screen: Tilt Function- XPPen Artist 13.3 Pro supports up to 60 degrees of tilt function, so now you don't need to adjust the brush direction in the software again and again. Simply tilt to add shading to your creation and enjoy smoother and more natural transitions between lines and strokes
- Graphics Tablets: High Color Gamut- The 13.3 inch fully-laminated FHD Display pairs a superb color accuracy of 88% NTSC (Adobe RGB≧91%,sRGB≧123%) with a 178-degree viewing angle and delivers rich colors, vivid images, and dazzling details in a wider view. Your creative world is now as powerful as it is colorful
- Drawing Pad: One is enough- The sleek Red Dial on the display is expertly designed with creators in mind, its strategic placement allows for natural drawing postures. With just one wheel, you can effortlessly zoom in and out, adjust brush sizes, and flip the canvas—all tailored to suit the habits of everyday artists. The 8 customizable shortcut keys allow you to personalize your setup, streamlining your workflow and enhancing creative efficiency
- Universal Compatibility & Software Support:supports Windows 7 (or later), Mac OS X 10.10 (or later), Chrome OS 88 (or later), and Linux systems. Fully compatible with major creative software including Photoshop, Illustrator, SAI, and Blender 3D. Register your device to access additional programs like ArtRage 5 and openCanvas for expanded creative possibilities.
Keep the background decision explicit
PNG can preserve transparent areas in the SVG when drawn onto a new canvas. JPEG cannot: transparent pixels have to become a solid color. The sample fills the canvas white before drawing when the requested type is JPEG. Replace white with the intended background color, or use PNG when transparency is part of the design.
Browser limitations and security pitfalls
SVG can be used as an image in HTML, CSS, certain SVG elements, and through the Canvas API, as MDN’s SVG guide explains. However, rendering an SVG as an image has restrictions: JavaScript in the SVG is disabled, and external images or stylesheets may be blocked. When appropriate, embed required resources in the SVG as data URLs rather than relying on remote references.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsCanvas export can also fail if pixels come from a cross-origin source that does not permit access. This is the canvas security model: drawing a remote image without suitable CORS permission taints the canvas, and export methods such as toBlob() or toDataURL() can raise a security error. Keep assets same-origin or configure the remote server to allow the required CORS access. Set img.crossOrigin before img.src for cross-origin image loading, but that setting alone cannot grant permission; the server must send appropriate CORS headers.
Fonts, CSS, SVG filters, and external references may render differently among browsers. If output fidelity matters, test the exported image in the browser and at the exact target dimensions, and ensure required fonts and assets are available to the renderer.
Convert SVG files with command-line tools
Use a command-line renderer when you need repeatable output, scripted jobs, or batch processing on a local machine or server. The best fit depends on rendering compatibility, installed fonts, sizing needs, and the SVG features in your files.
Rank #3
- Word-first 16K Pressure Levels: The upgraded stylus features 16,384 levels of pressure sensitivity and supports up to 60 degrees of tilt, delivering smoother lines and shading for a natural drawing experience. With no battery or charging needed, it operates like a real pen, making it easy for beginners to create effortlessly. This functionality helps novice artists develop their skills and explore their creativity without the intimidation of complex tools
- Designed for Beginners: This drawing pad desinged with 8 customizable shortcuts for both right and left-hand users, express keys create a highly ergonomic and convenient work platform
- Perfectly Adapted for Android: The XPPen Deco 01 V3 art tablet supports connections with Android devices running version 10.0 and above. It is recommended to download the XPPen Tools Android application, which adapts to your smartphone's screen aspect ratio, ensuring accurate mapping. It also supports mapping on Android screens with different aspect ratios in portrait mode
- Large Drawing Space, Bigger Bold Inspiration: This expansive drawing pad has10 x 6.25-inch helps you break through the limit between shortcut keys and drawing area
- Easy Connectivity for Beginners: The Deco 01 V3 offers USB-C to USB-C connectivity, plus adapters for USB C. This ensures easy connection to various devices, allowing beginner artists to set up quickly and focus on their creativity without compatibility concerns. Whether using a laptop, tablet, or desktop, the Deco 01 V3 provides a seamless experience, making it an ideal choice for those just starting their digital art journey
Inkscape: export SVG to PNG
Inkscape natively exports PNG. Its documented basic command is:
inkscape --export-type=png --export-filename=output.png input.svg
Use an explicit export width or height when the result needs a fixed pixel dimension. Inkscape’s documented command-line options include export sizing controls; consult the Inkscape command-line manual for the options available in your installed version. Inkscape does not natively export JPEG in the same way; its FAQ recommends exporting PNG and converting it with ImageMagick, GIMP, or an extension. For example, the documented pipeline pipes PNG into ImageMagick:
inkscape --export-type=png --export-filename=- input.svg | convert - output.jpg
For JPEG, set a background deliberately in the conversion step so transparent areas do not produce an unintended result. See Inkscape’s FAQ on JPEG export.
ImageMagick: convert and composite
A basic conversion is:
magick input.svg output.png
ImageMagick’s SVG rendering defaults to 96 dpi and it may use Inkscape, RSVG, or its internal renderer depending on what is available. That means different systems can produce different results if their renderer setup differs. Use explicit sizing controls when pixel dimensions matter, and choose a background for JPEG:
magick -background white input.svg output.jpg
For transparent PNG output, ImageMagick documents use of -background none. SVG parsing options also exist for entity substitution, embedded SVG, and unusually large documents. Do not relax parser protections or enable entity substitution for untrusted input; only use such options for SVG you trust. See ImageMagick’s SVG format documentation for renderer and parser details.
Rank #4
- Battery-Free Pen: StarG640 drawing tablet is the perfect replacement for a traditional mouse! The XPPen advanced Battery-free PN01 stylus does not require charging, allowing for constant uninterrupted Draw and Play, making lines flow quicker and smoother, enhancing overall performance
- Ideal for Online Education: XPPen G640 graphics tablet is designed for digital drawing, painting, sketching, E-signatures, online teaching, remote work, photo editing, it's compatible with Microsoft Office apps like Word, PowerPoint, OneNote, Zoom, Xsplit etc. Works perfect than a mouse, visually present your handwritten notes, signatures precisely
- Compact and Portable: The G640 art tablet is only 2 mm thick, it's as slim as all primary level graphic tablets, allowing you to carry it with you on the go
- Chromebook Supported: XPPen G640 digital drawing tablet is ready to work seamlessly with Chromebook devices now, so you can create information-rich content and collaborate with teachers and classmates on Google Jamboard’s whiteboard; Take notes quickly and conveniently with Google Keep, and effortlessly sketch diagrams with the Google Canvas
- Multipurpose Use: Designed for playing OSU! Game, digital drawing, painting, sketch, sign documents digitally, this writing tablet also compatible with Microsoft Office programs like Word, PowerPoint, OneNote and more. Create mind-maps, draw diagrams or take notes as replacement for mouse
librsvg: use rsvg-convert
The rsvg-convert utility is a scriptable option when its SVG feature support matches your project. A PNG export at a specified width is:
rsvg-convert --format=png --width=1600 --output=output.png input.svg
The height can be specified as well; librsvg can scale an image to fit a requested box while retaining the drawing’s proportions. The command reference also documents output formats and exporting a specific SVG object by its id. Parser guards can reject data URIs or unusually large documents unless limits are intentionally relaxed. Do not relax those limits for untrusted SVGs. See the rsvg-convert reference and librsvg documentation.
Choose the right conversion workflow
| Workflow | Best suited to | Important considerations |
|---|---|---|
| Browser Canvas | SVG generated in a web app; immediate download in the user’s browser | External resources and cross-origin images can block export; test fonts, filters, dimensions, and output format in target browsers. |
| Inkscape | Faithful desktop-style rendering and scripted PNG exports | For JPEG, export PNG and convert it; explicit export sizing is available. |
| ImageMagick | Pipelines that already resize, composite, or convert formats | Renderer selection can vary with installed dependencies; set output size and background intentionally. |
| librsvg / rsvg-convert | Lightweight scripted conversion when its SVG feature set fits | Use explicit output dimensions; parser guards can reject complex or large input. |
Before settling on a workflow, verify required pixel dimensions, transparency, font availability, external-resource policy, SVG filter support, batch volume, and destination formats. If output must match across machines, pin the renderer and relevant fonts rather than relying on whichever dependencies happen to be installed.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Batch conversion and operational considerations
For local batch work, wrap the selected command in a shell loop or your build system, but retain an explicit output naming rule and check each process’s exit status. Avoid overwriting source files, and preserve a separate directory for generated outputs. If a batch contains untrusted SVG input, keep parser protections enabled and limit input size; a complex or malicious document should not be given relaxed entity or document-size settings.
Resolution and dimensions drive memory use: a very large canvas or raster export can require substantial memory even when the SVG source text is small. Start with the actual delivery dimensions, not an arbitrarily huge export, and measure your own workload before increasing parallel conversions. Browser rendering also runs on the user’s device, so very large images may affect responsiveness. No single conversion speed or throughput figure applies across different SVGs, renderers, and hardware.
Best Value
- Please kindly note that GAOMON PD1161 drawing tablet is not a standalone tablet, It must be connected to a laptop or computer to work.
- [Create Right On Screen]: Sketch, draw and paint directly on the full HD 11.6" IPS screen of GAOMON PD1161 drawing tablet. And the pre-installed matte film on display makes it feel like sketching on paper while reducing uncomfortable glare and reflection at the same time.
- [Vivid Color Perfomance]: A combination of 72% NTSC (100% SRGB) color gamut and 16.7 million display colors enables to present your drawings in a more lifelike way with smoother color gradation on this drawing tablet for pc.
- [Battery-free Stylus AP50 ]: Say goodbye to the hassle of charging, GAOMON PD1161 graphics tablet includes a battery-free pen AP50 with 8192 levels of pressure sensitivity and tilt function, which is easy to control, giving you the familiar feel of standard pencil.
- [Customize Your Workflow]: The 8 press keys on the side of the PD1161 drawing monitor and 2 pen buttons can be programmble in the driver, which is great to get easy shortcus and improve workflow. Warm Reminder: it is not a standalone drawing tablet, so it should work with a computer running windows or mac OS.
For reliability, test representative files rather than only a simple rectangle: include any SVG features the real input uses, such as text, filters, embedded images, or CSS. Compare the same inputs at the same dimensions in the chosen renderer, and keep the renderer version stable when reproducibility matters.
Troubleshooting common SVG conversion failures
- The image is blank or clips its contents: Check the root
width,height, andviewBox; ensure the viewBox covers the drawing. Confirm that SVG text or paths are not positioned outside that coordinate area. - The browser reports a canvas security error: A drawn image came from an origin without suitable CORS permission. Keep assets same-origin or configure CORS on the asset server; setting a client-side cross-origin mode cannot replace server permission.
- Remote images, styles, or fonts are missing: SVG loaded as an image can block external resources. Inline assets where appropriate or make them available under a compatible origin and policy.
- JPEG has a black, white, or otherwise unexpected background: JPEG has no transparency. Paint the intended background before drawing, or export PNG instead.
- The requested JPEG or WebP becomes PNG: The browser may not support the requested type. Check the Blob’s
typeaftertoBlob(), and use a supported format or convert through a command-line tool. - The browser cannot create a Blob: Check for a null result, verify the SVG loaded, and ensure the 2D canvas context exists. Reduce extreme output dimensions if resource limits are involved.
- Command-line output differs between computers: ImageMagick can select different SVG renderers depending on installed Inkscape or RSVG components, while fonts and other dependencies also vary. Standardize the renderer and fonts for repeatable output.
- rsvg-convert or ImageMagick rejects a large or embedded SVG: The parser may be applying safety limits. Check the tool’s documented limits and input validity; only relax protections for input you trust.
Or skip the browser setup
If the image you need is already available as a webpage, ScreenshotNeo can capture that page with one API request rather than requiring you to build browser capture plumbing. It is a website screenshot API and MCP server from Yorker Media, not a general-purpose renderer for arbitrary SVG markup strings. Use the browser or command-line methods above when the SVG source itself is what you need to rasterize.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the capture; bot checks, blank pages, and failed loads are never billed; and an MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Frequently asked questions
Does converting SVG to PNG change the original SVG?
No. Rasterization creates a separate pixel-based output. Keep the SVG markup or file if you need to edit it or export again at another size.
Can I turn SVG into a JPEG without a white background?
JPEG does not support transparency. Choose a solid background color for the conversion or use PNG when transparent areas must remain transparent.
Can I convert an SVG code string without saving an SVG file?
Yes. In a browser, create a Blob from the string, load it through an object URL, draw the image to canvas, and export the canvas. That is the browser workflow described above.

