How to Make an Animated Code Video
Drop a file or describe a topic and AI writes a smooth code animation. Export a 16:9 or 9:16 MP4 in your browser, with captions, highlights and token morphs.
· 8 min read
Code Animation sample: Next.js after() in 16:9
Make a video like this with Code Animation
An animated code video shows how a snippet changes, not just how it looks when it is finished. Tokens that stay the same glide to their new place, removed code fades out, and new code fades in with a highlight, so a viewer can follow a refactor, a hook or an API without pausing a screen recording.
The video above is a real 12.5-second, 16:9 export from Code Animation. It walks through a Next.js server action that used to await an audit log before returning, then wraps that log in after() so the response can leave first. The filename, the purple highlight on the new import and the caption under the code are all part of the render.
You do not have to storyboard those steps yourself. Drop a file, paste the finished code, or describe the topic, and Animate with AI writes the sequence. Preview it, render the MP4 on your device, and click Download MP4 when it is ready.
What you need
- The finished code, or a clear topic ("explain JavaScript closures", "show how to debounce in React").
- A browser. The preview and the MP4 render on your computer; nothing is watermarked.
- A sign-in only if you use Animate with AI (from 25 credits; failed runs are free). Writing or tweaking the steps yourself, and exporting the MP4, stay free.
Three ways to start
Drop or paste a file. This is the usual path. Upload a .ts, .py, .go or similar file, paste the finished code, or paste a public GitHub gist or file link. Add an optional one-line brief if you want the video to emphasise something, pick 16:9 or 9:16 and a style, then click Animate with AI. It writes a short sequence of code states that build up to your exact finished file, with captions, highlights, focus, zoom and callouts.
Describe it. You do not need a file. Switch to Describe it and type what the video should explain. The AI writes short, working code step by step, then the same preview and export path. This is the right starting point when the job is "explain this idea," not "animate this repo file." See explain code with animation.
Write the steps yourself. Open Edit steps if you already know every frame, or if you want to tweak what the AI wrote. Export stays free.
How to make the video
- Open Code Animation.
- Drop a file, paste code, or paste a public GitHub gist or file link. Or switch to Describe it and type the topic.
- Choose 16:9 for YouTube, talks and docs, or 9:16 for Shorts, Reels and TikTok. Studio is the default look (code on a dark stage, with a rounded card in 9:16). Window adds a macOS-style chrome if you want that.
- Click Animate with AI. Watch the preview.
- Open Edit steps only if you want to change a caption, a highlight or a line of code.
- Click Download MP4. Rendering runs in your browser; the file is ready when the button says so. It does not download on its own.
For a vertical walkthrough, including layout tips that keep type readable on a phone, see how to make code reels and YouTube Shorts.
A real example: Next.js after()
The clip at the top of this page is the built-in "Run work after the response with after()" example, in Studio, 16:9, at 60 fps. The first step is the slow version: the handler waits for the audit log.
"use server"
import { db } from "@/lib/db"
import { audit } from "@/lib/audit"
export async function placeOrder(form: FormData) {
const sku = String(form.get("sku"))
const qty = Number(form.get("qty"))
const order = await db.orders.create({ sku, qty })
await audit.log("order.placed", { id: order.id, sku, qty })
return { id: order.id, status: order.status }
}
The second step imports after from next/server and moves the log so it runs once the response is already on its way. Unchanged tokens slide; the new import and the after() wrapper are highlighted; the caption under the code says what changed.
"use server"
import { db } from "@/lib/db"
import { audit } from "@/lib/audit"
import { after } from "next/server"
export async function placeOrder(form: FormData) {
const sku = String(form.get("sku"))
const qty = Number(form.get("qty"))
const order = await db.orders.create({ sku, qty })
after(async () => {
await audit.log("order.placed", { id: order.id, sku, qty })
})
return { id: order.id, status: order.status }
}
A still from the 16:9 export: the new after() import and call are highlighted, and the caption explains the change.
That is the whole point of a code animation: one idea, shown as a change, with a sentence that names it.
What makes the motion readable
- Whole-token morphs. Each step is tokenised with Shiki. Tokens that stay the same, including indent shifts, slide to their new place. The matcher works on whole tokens, so a word is not pulled apart into letters mid-move.
- A beat before the change. Lines that are about to change are highlighted first, so the eye is already there when the morph starts.
- New work is marked. New tokens fade in and get a short purple highlight. A caption under the code says what happened in that step.
- Constant 60 fps. The MP4 is rendered at a fixed frame rate in your browser.
Those details matter more than a long list of transition presets. If you are comparing libraries and apps, including Shiki Magic Move itself, see the Shiki Magic Move alternative guide.
Styles, aspect ratios and captions
Studio is the default: the code sits on a dark stage. In 9:16 it is a rounded card with the filename at the top, so the snippet is legible on a phone. Window is the macOS window look, with optional line numbers and a typing intro if you want them.
16:9 (1920×1080) suits YouTube, talks, docs and LinkedIn. 9:16 (1080×1920) suits Shorts, Reels and TikTok. You can pick either after the code is in; the layout is refit, not letterboxed.
Captions sit under the code, in a size that stays inside the Shorts and Reels safe area in 9:16. You can turn them off in the preview or in Edit steps if the video will sit under a voiceover. An optional watermark field is there if you want a handle on the clip.
TypeScript, JavaScript, TSX, Python, Go, Rust, Java, Kotlin, Swift, C, C++, C#, PHP, Ruby, Dart, SQL, shell, HTML, CSS, JSON, YAML and diffs are supported, with eight editor themes (GitHub, One Dark Pro, Tokyo Night, Dracula and others). Auto can pick a theme that suits the code.
Honest limits
- Animate with AI starts from 25 credits; failed runs are not charged. Manual steps and MP4 export are free, with no watermark.
- Your code stays in the browser until you click Animate with AI. Then the finished file and your optional brief are sent so the steps can be written. A gist or GitHub file is fetched straight from GitHub.
- Keep the tab open while the MP4 renders. Longer step lists take a little longer.
- This tool animates code. It does not add a voiceover, a talking-head crop or stock footage. For those jobs see the AI Video Editor. For type, charts and cards with no code in them, see AI Motion Graphics.
Code Animation
Drop a file and AI writes a smooth animated MP4. Export runs in your browser; failed AI runs are free.
Frequently asked questions
How do I make an animated code video?
Open Code Animation, drop a file or paste your code (or describe the topic), pick 16:9 or 9:16, and click Animate with AI. It writes the steps, captions and highlights. When the MP4 has rendered on your device, click Download MP4.
Do I have to write the before and after myself?
No. Animate with AI writes a short sequence of code states that builds up to your finished file. You can also switch to Describe it and type a topic, such as explain JavaScript closures. Open Edit steps if you want to change the result.
Is Code Animation free?
Previewing a sample, writing or tweaking steps yourself, and exporting the MP4 all run in your browser, with no watermark and no sign-in. Animate with AI starts from 25 credits, and failed runs are free.
What does the animation look like?
Each step is tokenised with Shiki. Tokens that stay the same slide to their new place, lines about to change are highlighted first, and new code fades in with a short highlight and a caption under the code. The MP4 is rendered at a constant 60 fps.
Can I make a vertical video for Shorts or Reels?
Yes. Pick 9:16 and export a 1080×1920 MP4. There is a separate guide for layout tips on phone-sized frames.
Try it on your code
Drop a file and AI writes a smooth animated MP4. Export runs in your browser; failed AI runs are free.
Open Code Animation