DOCS

Embedding guide

Embed a code animation anywhere

Drop an animated, syntax-highlighted typing demo into any place that renders images or Open Graph previews — a GitHub README, a docs site, a blog post, a Notion page, a Slack or Discord message, a LinkedIn post, a PR description, a VSCode markdown preview.

Two URL shapes cover every surface. They're produced automatically when you click Share in the editor (Pro tier):

URL Where it goes
/p/<id> Paste into Slack, X/Twitter, LinkedIn, Discord → rich unfurled preview card with animation thumbnail. Also: any chat, email, or doc where you want a clickable link.
/api/embed/<id>.svg Paste as an image source (<img> tag or Markdown ![](…)) → the animation plays inline, no link-click required. README, docs, blog, Notion.

No JavaScript. No <video> tag. Just text + an animated SVG that renders everywhere images render.

Table of contents

  1. Quickstart
  2. Markdown vs HTML
  3. Sizing
  4. Platform compatibility
  5. Two URL shapes: short vs hosted
  6. Updating an embed
  7. API keys & monthly quotas
  8. Signed URLs (no key in Markdown)
  9. Troubleshooting
  10. Copy-paste snippets

Quickstart

  1. Open the editor, paste your code, pick a theme.
  2. Click Export & Share, then either:
    • Copy link → pastes a https://codeanimate.dev/p/<id> URL. Drop it into Slack, a tweet, a chat, anywhere a preview card is nice.
    • Copy embed → pastes Markdown: ![name](https://codeanimate.dev/api/embed/<id>.svg). Drop it into a README, a docs page, a blog post, Notion.
  3. You'll also find the saved animation in your dashboard — rename, track hits, delete anytime.

The URL is permanent. The animation loops forever.

Markdown vs HTML

Both forms work. Use whichever is cleaner in the target file.

Markdown:

![hello.py](https://codeanimate.dev/api/embed/abc123.svg)

HTML (supported in GitHub README + most Markdown renderers):

<img src="https://codeanimate.dev/api/embed/abc123.svg"
     alt="hello.py"
     width="640" />

Use the HTML form when you need to constrain width, set align, or wrap the image in a link (<a href><img …/></a>).

Sizing

The SVG's intrinsic size matches the window you designed in the editor (including your stageWidth). To scale it in a README:

Form How to resize
Markdown Not possible — Markdown ![]() has no size attrs. Switch to HTML.
HTML <img> Add width="…" or style="max-width: 100%".
Anywhere Wrap in <p align="center">…</p> to center + scale responsively.

SVGs upscale without pixelation, so prefer width="640" (or whatever matches your content column) over exporting a larger PNG.

Platform compatibility

Platform SVG (animated) PNG GIF Notes
GitHub README / Gist / Issue / PR Served through GitHub's Camo proxy. Animation works.
VSCode markdown preview See VSCode-specific notes.
Cursor, other Electron-based editors Same renderer family as VSCode.
Read the Docs (Sphinx / MkDocs) Standard <img> tag.
Obsidian / Zed
Notion Embed as image block.
Slack unfurl (link preview) ⚠️ (frozen) Slack caches a static frame. Prefer .gif for previews.
npmjs.com package page
crates.io / PyPI ⚠️ These registries strip animated SVG in some cases — use .gif to be safe.
GitHub Marketplace extension README ⚠️ The Marketplace sanitizer strips SVG animation — use .gif.

Legend: ✅ = animation plays · ⚠️ = renders but animation is frozen or stripped · ❌ = image doesn't render.

Two URLs, two purposes

URL Purpose Where to paste
https://codeanimate.dev/p/<id> Human-facing page — shows the animation plus an OG preview when unfurled Slack, X/Twitter, LinkedIn, Discord, email, chat messages
https://codeanimate.dev/api/embed/<id>.svg Raw animated SVG <img> tags in READMEs, Markdown files, docs sites, Notion, anywhere images go

Both reference the same underlying snippet (same <id>). The editor's Share menu gives you both with one click each.

Programmatic creation (Pro API key):

curl -X POST https://codeanimate.dev/api/snippets \
  -H "Authorization: Bearer ca_live_abc…" \
  -H "Content-Type: application/json" \
  -d '{"snapshot":{"code":"…","filename":"hello.py","themeId":"dark-plus", …}}'
# → { "id": "k9X3mQ8vN2...", "url": "…/api/embed/k9X3mQ8vN2.svg", "markdown": "…", "html": "…" }

Shell-friendly shortcuts — pick a single output format instead of JSON:

curl -X POST '…/api/snippets?output=url' -H "…" -d @snap.json       # just the URL
curl -X POST '…/api/snippets?output=markdown' -H "…" -d @snap.json  # Markdown to paste
curl -X POST '…/api/snippets?output=svg' -H "…" -d @snap.json -o a.svg  # the rendered SVG

The language field is optional. The API will try:

  1. Filename extension (.py → python, .ts → typescript, .rs → rust, etc.)
  2. Content-based heuristic (detects python, js, ts, go, rust, java, c/cpp, sql, html, css, json, yaml, bash, markdown from the code itself)

Pass language explicitly only when both fail or the detection would be ambiguous (e.g. your .js file actually contains JSX).

Updating an embed

Hosted URLs are content-addressable: the id is a hash of your composition. Edit the code, theme, or timing, and you get a new id and therefore a new URL. Nothing is "in place" editable — that's a feature: CDNs cache the old URL safely, readers of older doc versions see the old animation, and you control rollout by swapping one URL.

From the Snippets dashboard, click Copy Markdown on the new snippet and paste over the old URL.

API keys & monthly quotas

Embeds are free and anonymous up to a small monthly per-IP cap, which is plenty for a few personal READMEs. For production docs, a blog, or anything that might go viral, create an API key so renders count against your own plan:

  1. Sign in at /dashboard/keys.
  2. Click Create key, give it a name (e.g. README dogfood).
  3. Copy the ca_live_… string — it's shown exactly once.
  4. Append ?k=ca_live_… to every embed URL.

Monthly quotas:

Tier Renders / month Watermark Notes
Anonymous (no key) 50 per IP Yes Graceful fallback SVG when exceeded.
Free (signed in) 10 Yes
Pro Unlimited No

When you hit your quota, the API returns a different SVG — a polite "quota reached" card — so the embed never breaks your page layout.

Signed URLs (no key in Markdown)

Some users prefer not to have an API key visible in a public README. A signed URL carries an HMAC instead:

![demo](https://codeanimate.dev/api/embed/k9X3mQ8vN2.svg?sig=…&exp=…)

Generate one from the key's settings page in the dashboard. The signature encodes your user id and an expiry; readers can still cache the image, but they can't use the URL beyond its expiry window.

Troubleshooting

"The animation isn't playing on GitHub." GitHub's Camo proxy caches very aggressively. After updating a snippet, append ?v=2 (or any cache-buster) to the URL in your README.

"Looks fine in the editor but broken on GitHub." Camo requires HTTPS + a valid Content-Type. Our API always sets those — if it still fails, check status.codeanimate.dev.

"Works in VSCode but not on GitHub (or vice versa)." Most often the viewer has Workspace Trust disabled, which blocks remote images entirely. The embed renders once you trust the workspace.

"I hit my quota mid-month." Upgrade to Pro for unlimited renders, or switch to the short-form /api/render?s=… URL which is rate-limited by IP rather than key.

"My code contains secrets — is this safe?" Hosted snippets are stored in our database. Don't paste API keys, tokens, or internal URLs into a public embed. The short-form URL encodes the code directly into the URL; it's equally public.

Copy-paste snippets

The ten most popular language/theme pairings, ready to adapt:

Language Theme Example embed
Python Dark Plus [/editor?lang=python&theme=dark-plus](/editor?lang=python&theme=dark-plus)
TypeScript Tokyo Night [/editor?lang=typescript&theme=tokyo-night](/editor?lang=typescript&theme=tokyo-night)
Rust Catppuccin Mocha [/editor?lang=rust&theme=catppuccin-mocha](/editor?lang=rust&theme=catppuccin-mocha)
Go GitHub Dark [/editor?lang=go&theme=github-dark](/editor?lang=go&theme=github-dark)
JavaScript One Dark Pro [/editor?lang=javascript&theme=one-dark-pro](/editor?lang=javascript&theme=one-dark-pro)
Java Dracula [/editor?lang=java&theme=dracula](/editor?lang=java&theme=dracula)
SQL Monokai [/editor?lang=sql&theme=monokai](/editor?lang=sql&theme=monokai)
HTML Night Owl [/editor?lang=html&theme=night-owl](/editor?lang=html&theme=night-owl)
Bash Nord [/editor?lang=bash&theme=nord](/editor?lang=bash&theme=nord)
Markdown GitHub Light [/editor?lang=markdown&theme=github-light](/editor?lang=markdown&theme=github-light)

Open the editor with the corresponding preset, paste your code, and click Copy README embed.


See also: VSCode preview notes · API reference · Quickstart