Saving web page screenshots as SVG using custom Ladybird
I've always wanted to save screenshots of webpages as SVG instead of .png. So today I figured: why not build my own version of Ladybird with this exact feature? The fork is on the svg-screenshots branch.
Web pages are inherently well suited for vector export: layouts, borders, shapes, gradients, and typography are already vector primitives. While a browser's typical "Print as PDF" covers full-page document output, taking screenshots today only exports raster PNG images.
Vector SVG screenshots are useful for documentation, technical writing, presentations, UI design software (such as Figma or Inkscape), and archiving web pages or selected regions at arbitrary zoom levels without pixelation.
Gemini 4 Neon told me it fits the codebase well, as Ladybird already splits rendering into a structured list of vector drawing commands and already has an interactive region, visible, and full-page picker. Three hours later, I had what I wish was a default in all browsers: Right click → Take Screenshot… with a PNG / SVG toggle.
Design
I kept the existing single Take Screenshot… entry point and added a PNG / SVG segmented toggle inside the screenshot selection overlay (defaulting to PNG), rather than adding extra context menu items. All three existing capture modes (Select Region, Capture Visible Page, and Capture Full Page) were wired to work in both PNG and SVG formats.
In headless mode (--headless=screenshot), I made it emit SVG automatically when --screenshot-path ends in .svg.
Looking ahead, when Ladybird later offers a File → Save As flow to export pages as .html, the same compositor SVG export path can be reused to offer .svg as an export format as well.
Examples
Every image below is a real SVG screenshot captured directly in Ladybird. Click any link to open the SVG in a new tab and zoom in.
How it works
Here's what my agent wrote:
Rather than rasterizing the page into tiles, a new
DisplayListPlayerSVGbackend inServices/Compositorwalks the resolved Rust display list and serializes each drawing command straight to SVG. Rectangles, rounded corners, paths, ellipses, gradients, clips, masks, filters, box shadows, and nested or out-of-process iframes (OOPIFs) stay vector, while preserving browser zoom, window resizes, and full scrolled document bounds. Text glyphs are extracted as HarfBuzz vector paths and deduplicated once in<defs>via<use>references, along with deduplicated clips, masks, filters, and gradients.To keep output clean and compact for vector editors like Inkscape, coordinates trim trailing zeros, redundant enclosing clips and empty
<g>wrappers are elided, and large fully-opaque bitmaps embed as JPEG (quality 88) while small graphics, transparent images, canvases, and color emoji stay lossless PNG. Non-sRGB CSS Color 4 gradients (oklch,oklab,lab,hsl,srgb-linear) sample intermediate sRGB stops via Skia to preserve browser interpolation, filters emituserSpaceOnUsebounds and native<feComposite>Porter-Duff operators, and 3D perspective transforms use exact projective w-division for plain geometry with Skia projective fallback for rounded shapes and text.Because SVG is an active document format and OOPIFs cross Site Isolation boundaries, capture runs exclusively over the trusted browser
CompositorPresentationServer/CompositorPresentationClientIPC channel so untrustedWebContentonly flushes its display list and never receives or can forge SVG output. Inside the shared Compositor process, the serializer enforces a 64 MiB output budget, caps filter recursion depth at 64, validates capture bounds and resource lookups, and is covered by unit tests inTestDisplayListPlayerSVGandTestScreenshotSelectionOverlay.
Try it
Clone the svg-screenshots branch of steren/ladybird and build Ladybird, then right-click any page → Take Screenshot… and flip the overlay toggle to SVG, or capture headlessly from the command line:
./Meta/ladybird.py run ladybird --headless=screenshot --screenshot-path page.svg https://example.com
I hope this feature makes it upstream, and I welcome the Ladybird maintainers to use the prototype code. Issue #16430 has been opened to track the feature request.
See also fathyb/html2svg for a similar project where the author built a custom Chromium container to export web pages as SVG.