--- title: Image export created_at: 12/20/2025 updated_at: 12/20/2025 keywords: - export - SVG - image - PNG - download status: published date: 12/20/2025 readability: 9 voice: 8 completeness: 9 accuracy: 10 notes: '' --- The export system converts shapes to SVG and raster image formats for download, embedding, or integration with external tools. The editor handles the full pipeline from rendering shapes as SVG to converting those SVGs into PNG, JPEG, or WebP images. Exports are fully self-contained: the editor embeds fonts, inlines styles, and converts media elements to data URLs. ## How it works Export has two stages: SVG generation and optional raster conversion. The SVG stage renders shapes into a self-contained SVG document, while the raster stage converts that SVG into a bitmap image. ### SVG generation The editor gathers the shapes to export, calculates their bounding box, creates a React tree representing the SVG, renders it into a temporary DOM element, and processes it to be self-contained. Each shape defines how it renders to SVG through its [ShapeUtil](?). If the shape implements [ShapeUtil#toSvg](?) or [ShapeUtil#toBackgroundSvg](?), those methods return React SVG elements. Otherwise the editor renders the shape's normal HTML inside an SVG `` element. ```tsx override toSvg(shape: MyShape, ctx: SvgExportContext) { const fill = ctx.isDarkMode ? '#333' : '#eee' return } ``` The [SvgExportContext](?) tells you the color mode, `scale`, and `pixelRatio` of the export, resolves asset URLs at the right size via `resolveAssetUrl`, and lets you defer the snapshot with `waitUntil` while an image loads. Shapes rendered through `` can do the same with [useDelaySvgExport](?). The temporary render step is necessary because CSS and layout aren't computed until elements are in the document. `` elements in particular need their styles and content inlined to work when the SVG is extracted. ### Making SVG self-contained SVG files must be self-contained to work outside the document. The editor processes the rendered SVG to embed all external resources: Fonts come first. The `FontEmbedder` finds `@font-face` declarations in the document's stylesheets, fetches the font files, and inlines them as data URLs, so text renders identically regardless of what the viewer has installed. Then styles. The `StyleEmbedder` reads computed styles from every element inside `` sections and writes them as inline styles. Pseudo-elements like `::before` and `::after` can't be inlined, so their rules go into a `