# SVG Editor (svg.giit.ch) > Free SVG editor in the browser, with no sign-up and no upload. Edit SVG code with syntax highlighting, move, resize, rotate, flip and recolor shapes on the canvas, use an adjustable snap grid and export to SVG, PNG, JPG, WebP, data URI, CSS or a React component. - Language: English - Cost: free - Data: the drawing stays in the browser; a draft is kept in the browser's local storage. ## Features - Code and preview side by side, linked both ways: changes in the code appear in the preview at once, changes on the canvas appear in the code at once. - Select, move, resize, rotate in 15° steps, flip, duplicate, arrange, delete. - Fill, outline, opacity, outline width, line style, line ends and corners. - Drawing tools: rectangle, ellipse/circle, line, freehand, text. - Grid with adjustable spacing and snapping (can be switched off while the grid stays visible). - Tidy up and shrink SVG code. - Export: SVG, PNG, JPG, WebP, data URI, Base64, CSS background-image, HTML img, React (JSX). - My drawings: any number of drawings kept in the browser - open, rename, duplicate, download (one or all as ZIP) and delete them. - Light, dark or automatic color theme. - AI Assistant: any AI can draw in the editor through links (see below). - Save to your own server with a webhook, or embed the editor in your website (see below). ## Drawing for a user (for AI assistants) Any AI can show a drawing in the user's open editor with a link; no server, no API key: - `https://svg.giit.ch/#b64=` - `https://svg.giit.ch/#svg=` - `https://svg.giit.ch/#z=` (shorter) - Add `&mode=add` to add only elements on top of the current drawing. - Add `&file=new&name=` to make a new drawing next to the user's others, or `&file=` to change that one of the user's drawings. Without `&file=` the open drawing changes. - Long drawings: split the encoded text and send one link per part with `&part=N&of=M&id=`. The root must be ``. Open the link in the user's browser if you can, otherwise give it to the user to click. The user can undo every change. In the editor, "AI Assistant" > "Copy prompt" gives the AI these instructions together with the current drawing. ## Saving on your own server (webhook) Set under "Save to server" (cloud button), or for one drawing with `?webhook=`: only for that one drawing and only while the page is open - a link never stores a webhook. At the top level the user is asked first; inside a page (iframe or opener) it only works together with `?src=` and only for the drawing opened with it. On "Save" (Ctrl+S), or automatically a few seconds after each change if chosen, the browser sends `POST ` with `Content-Type: application/json`, `Authorization: Bearer ` (if a token is set) and the body `{"editor":"svg","event":"save","id","name","content":"","updated":""}`. One request carries at most 40 MB; the server's error text (e.g. for 413) is shown to the user. The server must answer CORS requests from https://svg.giit.ch. `?src=` opens an .svg file from a URL (CORS needed), `&name=` names it. ## Embedding in a website ``, then postMessage (check `event.origin === "https://svg.giit.ch"` and `event.source`): - Editor -> page: `{type:"svgeditor:ready", version:2, editor:"svg", window:false}`. - Page -> editor: `{type:"svgeditor:load", name, content}` opens the drawing (one of that name is replaced, otherwise made); answer `{type:"svgeditor:loaded", name}`. - Editor -> page: `{type:"svgeditor:change", id, name, content}` on edits (not after load), `{type:"svgeditor:save", id, name, content, …}` when the user clicks Save or presses Ctrl+S. - Page -> editor: `{type:"svgeditor:get"}` asks for a save message. The LaTeX Editor (latex.giit.ch) speaks the same protocol with the prefix `latexeditor:`. Optional fields of `svgeditor:load`: - `context: {host, title, rules}` - plain text about the page (rules up to 2000 characters). "Copy prompt" in the AI Assistant then tells the AI that the drawing belongs to that page and is saved back there, includes the rules, and leaves out how to build a webhook server. - `hook: {url, token}` - a webhook (https) for this drawing only, used on Save in addition to the message; kept in memory only (never stored, gone on reload). If the server answers with an error, its `{"error": "…"}` (or `message`, or a short text) is shown to the user. AI Assistant in a frame: add `allow="clipboard-write"` to the iframe so "Copy prompt" can use the clipboard (without it the editor falls back to the old copy command or shows the prompt to copy by hand). Links from an AI cannot reach an editor inside another website (the browser keeps its storage and channels apart), so in a frame the prompt and the dialog ask to paste the AI's whole answer into the editor; use the own window (below) if links should work. `svgeditor:get` is always answered with a `svgeditor:save` message, also when nothing changed. ### All messages at a glance Editor -> page (sent to the page around the editor, or to window.opener in its own window): - `svgeditor:ready` {version:2, editor, window} - can take a drawing - `svgeditor:loaded` {id, name, target?} - after each load; remember the id (target:"new" for a new drawing from the AI, which is not yours) - `svgeditor:change` {id, name, content} - a real edit of your drawing (not after load) - `svgeditor:save` {editor, event, id, name, content, updated} - Save / Ctrl+S (from anywhere in the editor), or the answer to get. Pictures inside a drawing are part of its code (``, data URIs); the SVG Editor has no separate files - `svgeditor:closing` {id, name, content} - own window closed with unsaved changes - `svgeditor:reload` {id, unsaved} - inside your page, F5 / Ctrl+R / Cmd+R do not reload the editor; ask the user yourself (Ctrl+W cannot be caught by a page) - `svgeditor:key-request` {reason:"missing"} - the editor has no AI key in this session yet `?embed=1&save=0` hides the editor's Save button (Ctrl+S still sends `svgeditor:save`) - for pages with their own Save button. `?lang=de` shows the editor's interface in German (menus, buttons, dialogs, messages), `?lang=en` in English (the default); the choice is remembered in the browser. The AI prompt is always English. Page -> editor (only from the page around the editor or the opener; after its first message only from that origin; pages without a real origin are ignored): - `svgeditor:load` {name, content, context?, hook?, ai?, from?, target?} - open your drawing; from:"ai" shows a note, target:"new" opens it as a separate drawing in the user's browser - `svgeditor:get` - answered with `svgeditor:save` of your drawing (id and content null before the first load) - `svgeditor:save` - press Save - `svgeditor:ai` {label?, prompt?, endpoint?, key?, base?} or {clear:true} - AI through your server Your drawing is the one your page loaded (or opened with ?src=). change, save, closing and get are only ever about it - never about other drawings in the user's browser, also when the user opens them in the editor. A load replaces only a drawing that came from your page before (same name and origin), never the user's own; the AI settings and the hook from load apply only while your drawing is open. ### AI through your own server (prompt and session key) The editor has no backend; your site keeps the keys and the results. Hand the editor your prompt, an endpoint and a key for this editor session - in `svgeditor:load` as `ai: {…}`, or at any time as its own message: {type:"svgeditor:ai", label:"Example Admin", prompt:"", endpoint:"https://your-site.com/api/ai-result", key:"", base:true} Fields left out keep their value; `{type:"svgeditor:ai", clear:true}` ends it. One key per editor session: once the editor has a key it keeps it until the session ends or `clear`, and does not take a different one. `base:false` leaves out the editor's own instructions. The AI dialog shows "Connected to