Drop an SVG, get back a structured JSON tree in the Polotno design schema — every element typed (text, image, svg, line, group), every property explicit. Not the raw XML tree as JSON; a higher-level format built for canvas editors and programmatic manipulation.
What the JSON looks like
The output is a Polotno design: a top-level width / height and a pages array (always one page for an SVG input). Each page has a children array of typed elements — text, image, svg (for path-heavy fragments), line, group. Geometry is in pixels; colors are hex strings.
Use cases
- Loading SVG assets into a canvas editor — the Polotno editor SDK loads this JSON directly via
store.loadJSON(). Useful when shipping SVG icon libraries as editable starting points in a design tool. - Programmatic edits — tweak colors, positions, or text values via straight object access, then re-render.
- LLM-friendly data— feed the structured tree to a model that's better at JSON than at SVG markup.
The same conversion in code
import { svgToJson } from "@polotno/svg-import";
const text = await file.text();
const json = await svgToJson({ svg: text });
// Load into a Polotno store
import { createStore } from "polotno/model/store";
const store = createStore({ key: "YOUR_KEY" });
store.loadJSON(json);Full API reference: SVG Import docs.
