SVG Editor online

Code

Export

Width and height stay in proportion. JPG has no transparency, so it always gets a background.

My drawings

Click a drawing to open it. They are stored only in this browser - nothing is uploaded. Clearing the browser's site data removes them, so download the ones you want to keep.

AI Assistant

Any AI can draw with you - ChatGPT, Claude, Gemini, Copilot.

  1. Click Copy prompt.
  2. Paste it into your AI and say what it should draw.
The AI should

The drawing travels in the link after the “#”, which no server sees. What you paste into your AI is handled by its provider.

Save to your server

The editor can send each saved version to your own server (a webhook), so your drawings are kept where you want them. Nothing is sent until you enter an address here.

What your server receives

A POST request with JSON (your server must allow CORS from https://svg.giit.ch):

{ "editor": "svg", "event": "save", "id": "…", "name": "Logo",
  "content": "<svg xmlns=\"http://www.w3.org/2000/svg\" …>…</svg>",
  "updated": "2026-01-15T09:30:00.000Z" }
Embed the editor in your website
<iframe src="https://svg.giit.ch/?embed=1" style="width:100%;height:80vh;border:0"></iframe>
<script>
const frame = document.querySelector('iframe');
addEventListener('message', e => {
  if (e.origin !== 'https://svg.giit.ch' || e.source !== frame.contentWindow) return;
  if (e.data.type === 'svgeditor:ready')
    frame.contentWindow.postMessage({ type: 'svgeditor:load', name: 'Logo',
      content: '<svg …>…</svg>' }, 'https://svg.giit.ch');
  if (e.data.type === 'svgeditor:save') saveOnYourServer(e.data.content);
});
</script>

Also possible: ?src=<URL of an .svg file> opens a file, &webhook=<URL> saves this drawing there. The editor can also open in a window of its own (?embed=window), and your page can hand it its own AI prompt and a session key so the AI sends its result to your server (svgeditor:ai, svgeditor:key-request) - see "Use the editor on your own website" below the editor. Details are in llms.txt.

Help

How it works

  1. Open an SVG file, drag it into the window or paste SVG code - or start with New.
  2. My drawings (the folder button at the top left) lists every drawing kept in this browser: open, rename, duplicate, download or delete them.
  3. Click a shape on the canvas. Drag it to move it, drag the small squares to resize it. Colors, size and position are under Properties on the right.
  4. Draw new shapes with the tools above the canvas.
  5. The code on the left always shows the current drawing and can be edited directly.
  6. Download SVG saves the file, Export offers pictures (PNG, JPG) and code for websites.

Made a mistake? Undo takes back every step. Your drawings are kept in this browser, even after closing the page.

Keyboard shortcuts

V
Select and move
R E L P T
Rectangle, ellipse, line, freehand, text
H / hold Space
Move the view
Mouse wheel, + -
Zoom
Drag with the mouse wheel pressed
Move the view
Double-click the mouse wheel
Fit to window
0 / 1
Fit to window / actual size
# / G
Grid on/off / snap on/off
Arrow keys
Move the selection by 1, with Shift by 10
Shift while dragging
Only horizontal/vertical, keep proportions
Alt + click
Select the surrounding group
Delete
Remove the selection
Ctrl + D
Duplicate
Ctrl + ↑ / ↓
Forward / backward (with Shift: to front / to back)
Ctrl + Z / Y
Undo / redo
Ctrl + S / E
Download SVG (or save to your server) / export
Ctrl + O
My drawings
Esc
Deselect

In the code: Tab indents, Shift+Tab outdents, clicking into a tag selects that shape on the canvas.

在线查看、编辑和导出 SVG

SVG 编辑器将你的绘图和代码并排显示。你在代码中做的任何修改都会立即出现在预览中;你在画布上移动、调整大小或改色的内容也会反映到代码里。这样无需打开大型图形软件,就能快速调整图标、标志、图表和插画。

一切都在你的浏览器中运行。文件不会上传,无需注册,也没有广告。

编辑器的功能

代码高亮

标签、属性和值各有颜色,带行号,用 Tab 缩进,自动闭合标签,并给出带行号的清晰错误信息。

直接编辑图形

点击、拖动、用控制点调整大小、旋转、翻转、复制、上移或下移:矩形、圆、路径、多边形、文字和组。

颜色和轮廓

用取色器或数值设置填充和轮廓,不透明度、轮廓宽度、虚线、圆形或方形线端。

网格与吸附

任意网格间距,使用绘图自身的坐标。图形会精确吸附到网格线上;取消勾选“吸附”即可自由移动。

绘图工具

矩形、椭圆、圆、直线、自由绘制和文字,新图形的颜色可自选。

导出

SVG(原样、整理后或压缩后)、透明背景的 PNG、JPG、WebP、Data URI、Base64、CSS 和 React 组件。

使用方法

  1. 打开 SVG:选择文件、将其拖入窗口或粘贴代码。
  2. 编辑:在代码中输入,或在画布上点击、拖动图形,并在右侧设置颜色。
  3. 导出:选择格式,为图片设置尺寸,然后下载或复制。

在你自己的网站上使用编辑器

任何 https 页面(以及 localhost)都可以用 <iframe> 和 ?embed=1 嵌入编辑器,无需注册,无需密钥。嵌入后,编辑器会隐藏这段文字并显示“保存”按钮。有两种方式传入和取出绘图。

1. 从链接打开文件,保存到你的服务器

src= 打开一个文件(你的服务器必须允许 CORS),webhook= 让“保存”(Ctrl+S)把绘图发送到该地址。加上 &token=… 可发送 Authorization: Bearer … 请求头,加上 &auto 则每次更改后都会保存。

<iframe src="https://svg.giit.ch/?embed=1&src=https://your-site.com/docs/logo.svg&webhook=https://your-site.com/save.php"
        allow="clipboard-write" style="width:100%;height:800px;border:0"></iframe>

Webhook 会收到一个带 JSON 的 POST 请求 { editor, event: "save", id, name, content, updated }。一个保存它的简短 PHP 脚本:

<?php
header('Access-Control-Allow-Origin: https://svg.giit.ch');
header('Access-Control-Allow-Headers: Content-Type, Authorization');
header('Access-Control-Allow-Methods: POST, OPTIONS');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') exit;
if (($_SERVER['HTTP_AUTHORIZATION'] ?? '') !== 'Bearer SECRET') { http_response_code(403); exit; }
$d = json_decode(file_get_contents('php://input'), true);
$name = preg_replace('/[^\w\- ]/u', '_', $d['name']);
file_put_contents(__DIR__ . "/docs/$name.svg", $d['content']);
echo '{"ok":true}';

2. 由你的页面保存绘图(postMessage)

编辑器发送 svgeditor:ready,你的页面以 svgeditor:load 回应,编辑器报告 svgeditor:loaded,有实际编辑时发送 svgeditor:change,用户保存时发送 svgeditor:save。你的页面可以发送 svgeditor:get(获取当前状态)或 svgeditor:save(相当于点击“保存”)。这样保存就通过你自己的登录和会话进行。

<iframe id="ed" src="https://svg.giit.ch/?embed=1" allow="clipboard-write" style="width:100%;height:800px;border:0"></iframe>
<script>
const ed = document.getElementById('ed');
const ORIGIN = 'https://svg.giit.ch';

addEventListener('message', async e => {
  if (e.source !== ed.contentWindow || e.origin !== ORIGIN) return;
  const m = e.data;
  if (m.type === 'svgeditor:ready') {             // 编辑器已就绪:把绘图交给它
    ed.contentWindow.postMessage({
      type: 'svgeditor:load',
      name: 'Logo',
      content: await (await fetch('/docs/logo.svg')).text(),
    }, ORIGIN);
  }
  if (m.type === 'svgeditor:change') document.title = '● not saved';   // 一次实际编辑
  if (m.type === 'svgeditor:save') {              // 用户点击了“保存”
    await fetch('/api/save', { method: 'POST', headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ name: m.name, content: m.content }) });
    document.title = 'Saved';
  }
});

// 你自己页面上的保存按钮:回应以 svgeditor:save 返回
function saveNow() { ed.contentWindow.postMessage({ type: 'svgeditor:get' }, ORIGIN); }
</script>

页面内的 AI 助手:在框架中同样可用。在 iframe 上设置 allow="clipboard-write" 后,“复制提示词”会直接使用剪贴板(否则编辑器会退回旧的复制命令,或显示提示词供手动复制)。AI 发送的链接无法到达另一个网站中的编辑器,因此编辑器会提示 AI 和用户把 AI 的完整回答粘贴到编辑器中,或在单独的窗口中打开编辑器。

3. 在单独的窗口中

window.open("https://svg.giit.ch/?embed=window", "svgeditor-17") 会在单独的窗口中打开完整的编辑器,并通过 window.opener 使用相同的消息。AI 的链接可以到达那里。svgeditor:load 还可以带上 context: { host, title, rules }(AI 提示词随后会说明绘图属于哪里,并遵循你的规则),以及 hook: { url, token },即仅用于此绘图、从不保存的 Webhook。关闭有未保存更改的窗口时会发送 svgeditor:closing。

4. 通过你自己的服务器使用 AI

向编辑器提供你自己的提示词、你网站上的一个地址和本次编辑器会话的密钥。AI 对话框随后会显示“已连接到”你的网站、你告诉 AI 的内容,以及修改当前绘图或新建一个绘图的选项;复制提示词会把这些都组合起来。AI 带着密钥把结果发送到你的服务器,你的页面再在编辑器中打开它;新绘图会单独打开,并保留在用户的浏览器中。每个编辑器会话一个密钥:编辑器打开期间有效,只有在没有密钥时,编辑器才会用 svgeditor:key-request 请求。编辑器自己从不发送密钥,也从不保存它;地址必须是你自己主机或其子域名上的 https 地址。

const key = async () => (await fetch('/api/ai-key.php?doc=17')).json();   // 每个编辑器会话一个密钥
const k = await key();
ed.contentWindow.postMessage({ type: 'svgeditor:load', name: 'Flyer', content, ai: {
  label: 'My Site', prompt: 'Keep the [[placeholders]]. Write in German.',
  endpoint: 'https://your-site.com/api/ai-result.php', key: k.key } }, ORIGIN);
// 记住 svgeditor:loaded 中的 id,忽略 id 不同的 change/save/closing
// 仅在编辑器没有密钥时:
if (m.type === 'svgeditor:key-request') { const k = await key(); ed.contentWindow.postMessage({ type: 'svgeditor:ai', key: k.key }, ORIGIN); }
// 编辑器打开期间,每分钟通知你的服务器;关闭编辑器或页面会使密钥作废
setInterval(() => fetch('/api/ai-key.php?alive=' + k.key.slice(0, 8)), 60000);
// 你的服务器有了结果(轮询、SSE …):target 为 "current" 或 "new"
ed.contentWindow.postMessage({ type: 'svgeditor:load', name: 'Flyer', content: draft, from: 'ai', target }, ORIGIN);
<?php // api/ai-key.php:已登录用户本次编辑器会话的密钥(由你的页面调用)
session_start();                                     // 检查用户是否可以编辑此绘图
$key = bin2hex(random_bytes(24));
$_SESSION['ai'][hash('sha256', $key)] = ['doc' => (int)$_GET['doc'], 'seen' => time()];  // 或存入你的数据库;?alive= 会重新设置 seen
echo json_encode(['key' => $key]);

<?php // api/ai-result.php:AI 向这里发送(无需 CORS 头:AI 从服务器调用它)
$key = preg_replace('/^Bearer\s+/', '', $_SERVER['HTTP_AUTHORIZATION'] ?? '');
$row = find_key(hash('sha256', $key));               // 你的数据库:未作废,且在最近 3 分钟内出现过
if (!$row) { http_response_code(401); exit('{"ok":false,"error":"key not valid"}'); }
$d = json_decode(file_get_contents('php://input', false, null, 0, 2000000), true);
save_draft($row['doc'], $d['content'], $d['target'] === 'new' ? 'new' : 'current');   // 你的页面用 svgeditor:load 显示它
echo '{"ok":true}';

密钥至少使用 128 位随机数,只保存其哈希值,将每个密钥绑定到已登录用户、绘图和本次编辑器会话,每个会话一个,仅在你的页面报告会话仍打开时有效,并在编辑器或页面关闭时作废。

完整协议见 llms.txt,把它交给 AI,AI 就能为你的系统建立连接。LaTeX 编辑器的用法相同,前缀为 latexeditor:,见 latex.giit.ch。

常见问题

我的 SVG 文件会被上传吗?

不会。编辑器完全在你的浏览器中运行。你打开的文件和你的代码绝不会发送到服务器;草稿只保存在浏览器的本地存储中。

我的绘图保存在哪里?

只保存在你的浏览器中。编辑器可以在那里保存任意数量的绘图,点击左上角的文件夹按钮(我的绘图)即可打开、重命名、复制、下载或删除它们。不会上传任何内容;清除浏览器的网站数据会删除它们,因此请下载需要保留的绘图。

如何将 SVG 转换为 PNG?

打开或粘贴你的 SVG,点击“导出”,选择 PNG,选择尺寸(1×、2×、4× 或自定义),再点击“下载”。除非你选择了颜色,否则背景保持透明。

可以用鼠标编辑图形吗?

可以。点击图形即可选中。你可以拖动它,用小方块调整大小,旋转、翻转和改色。左侧的代码会随之改变。

网格有什么用?

网格以绘图自身的坐标显示辅助线。开启后,你移动或绘制的图形会精确吸附到网格线上。取消勾选“吸附”可保留网格显示,同时自由移动图形。

可以把 SVG 用作 React 组件吗?

可以。在导出中选择“React 组件(JSX)”。stroke-width 等属性会变为 strokeWidth,class 变为 className,组件还可以接收其他 props。

AI 能在 SVG 编辑器中绘图吗?

能,任何 AI 都可以:ChatGPT、Claude、Gemini、Copilot 或你编程工具中的 AI。点击“AI 助手”,再点击“复制提示词”,粘贴到你的 AI 中并说明要画什么。AI 会回复一个链接;点击它,绘图就会出现在你的编辑器中。它可以修改当前打开的绘图,也可以在其他绘图旁边新建绘图。无需安装任何东西,“撤销”可撤回每一处更改。

我可以在自己的网站上使用编辑器吗?

可以。用 iframe 嵌入它并通过 postMessage 交换绘图,或让它通过 Webhook 把每个保存的版本发送到你的服务器。示例见在你自己的网站上使用编辑器。

SVG 编辑器收费吗?

不收费。编辑器免费,没有广告,无需注册。