What is the SVG to Canvas Code Converter?
Canvas is fast for games and animations, but drawing by hand is slow. Paste your SVG and get JavaScript that draws the same picture with the canvas 2D context.
Paths, rectangles, circles, ellipses, text, groups, transforms, colours, opacity, strokes and simple gradients are supported. You can also choose Path2D, which keeps long paths as short strings. Parts that cannot be turned into canvas code are listed in a note.
How to use it
- Paste your SVG code, or open an .svg file.
- Pick a function name and the path style.
- Copy the JavaScript and run it on your canvas.
Why people like this tool
Real drawing code
moveTo, lineTo, bezierCurveTo and more.
Path2D option
Short code for long paths.
Colours and strokes
Fill, stroke, opacity and gradients.
Honest notes
Lists what could not be converted.