Animation2Code: Evaluating Temporal Visual Reasoning in Video-to-Code Generation

Anya Ji, Abhijith Varma Mudunuri, David M. Chan, Alane Suhr

TL;DR

Vision-language models (VLMs) have gotten surprisingly good at looking at a static screenshot of a webpage and writing the HTML/CSS to recreate it. But what happens when things start moving? Animation2Code tests whether VLMs can "de-render" web animations—watching a short video and writing executable code that reproduces both the visuals and the motion. The verdict: while top models can nail the static look and write runnable code nearly 100% of the time, they consistently flop at capturing the actual timing and trajectory of the motion.

What Problem Does This Paper Address?

Static visual-to-code generation—turning screenshots of webpages, charts, or slides into code—is a well-studied problem. Dynamic visual perception, however, is a different beast. Understanding a video requires tracking objects across frames, figuring out how their positions or shapes evolve, and translating that continuous motion into discrete programmatic logic (like CSS @keyframes or JavaScript).

Existing video benchmarks mostly test comprehension through question-answering (e.g., "What happened first?"). They don't require the model to reconstruct the underlying mechanics. By framing the problem as animation de-rendering—mapping a reference video to an executable HTML file—the authors test whether VLMs truly understand temporal dynamics, not just static layouts.

Figure 1: Animation2Code is the first benchmark to evaluate de-rendering of web animations to executable code. Animation2Code comprises 1,069 high-quality web animation videos (four examples shown, five uniformly sampled frames each from videos rendered at 30 FPS) paired with HTML/CSS/JavaScript code (right).

Methods

To evaluate whether a generated animation actually matches the target, the authors needed metrics that separate how it looks from how it moves. First, they crop both the reference and generated videos to their respective animated bounding boxes so that absolute positioning on the page doesn't skew the scores. Then they compute two human-aligned metrics:

  • Appearance Similarity: Uses DreamSim (a perceptual image embedding) combined with Dynamic Time Warping (DTW) to align frames between the two videos and measure visual fidelity—color, shape, and style—even if the timing is slightly off.
  • Temporal Similarity: Uses CoTracker3 to extract motion trajectories ("tracklets") from a 30×30 grid of changing pixels. It compares the direction and speed of these trajectories between the ground truth and generated videos, aggregating them with a Chamfer-style matching.
Figure 2: Evaluation metrics for Animation2Code. We isolate animated regions via cropping, com- pute appearance similarity using DreamSim with DTW alignment, and measure temporal similarity via tracklet displacement correlation aggregated with a Chamfer-style matching.

The authors validated both metrics against 600 pairwise human judgments collected via Prolific. Combining the two metrics with logistic regression aligned best with human preferences, achieving test accuracies of 83.9% (overall), 82.2% (appearance), and 81.2% (temporal).

Datasets

The authors introduce Animation2Code, a new benchmark curated from 1,069 publicly available CodePen examples.

  • Format: Each example is normalized into a single executable HTML file with inline CSS and/or JavaScript, then deterministically rendered into a 1024×768 MP4 video at 30 FPS (lasting 2–8 seconds, mean 5.1s).
  • Diversity: 83.3% are pure CSS animations, 15.8% use JavaScript, and 0.9% use SVG alone. Over 65% combine three or more motion patterns (like rotation, translation, and scaling).
  • Splits: 72% train, 8% validation, and 20% test, grouped by source to prevent data leakage.

Unlike prior benchmarks such as Design2Code (static webpages) or WebVR (user-triggered interactions), Animation2Code is the first to focus on continuous, time-driven web animations.

Key Insights and Ideas

  • High appearance does not mean good motion: Models that excel at recreating the visual style of an animation still struggle to get the timing, direction, or trajectory right.
  • Fine-tuning can actually hurt: Fine-tuning Qwen3-VL-8B-Instruct (via LoRA or full-parameter SFT) improved code execution rates by teaching the model proper HTML structure, but degraded both appearance and temporal similarity. Why? Optimizing for code-level tokens doesn't guarantee visual fidelity—in fact, static renders (code that executes but doesn't move) jumped from 4.4% to 11.8%.
  • More frames aren't a silver bullet: Feeding native video at higher frame rates (up to 16 or 24 FPS) only yielded marginal gains, suggesting the bottleneck is temporal reasoning, not input resolution.
  • Iterative refinement helps: Adapting a multi-agent refinement loop (METAL), where visual and code critics give feedback over three iterations, boosted both appearance and temporal scores.

Key Results

Evaluating five state-of-the-art commercial and open-source VLMs (GPT-5.4, Gemini 3 Flash Preview, Claude Sonnet 4.6, LLaMA 4 Scout, and Qwen3-VL-8B-Instruct) revealed a stark gap between static and dynamic performance:

  • Execution & Appearance: Most frontier models achieved near-perfect code execution (≥97%, with GPT-5.4 and Gemini 3 Flash Preview hitting 100.0%). GPT-5.4 led in appearance similarity (0.84), followed by Claude Sonnet 4.6 (0.82) and Gemini 3 Flash Preview (0.81 at 4 FPS).
  • Temporal Similarity: Scores remained uniformly low across every model and setting, peaking at just 0.32 (Gemini 3 Flash Preview at 16 FPS native video).
  • Human Preferences: In pairwise human evaluations, GPT-5.4 was the most preferred model overall, while LLaMA 4 Scout performed worst (and produced static, non-moving renders 12.0% of the time).
Figure 3: Pairwise win rates from human preference annotations (ties excluded). Rows indicate the preferred model over columns. GPT-5.4 is the most preferred over all tested models. Models that excel in appearance do not consistently achieve better temporal alignment.

Limitations and Future Work

The authors note two main limitations:

  1. Tracker noise: CoTracker3 is trained on natural videos rather than synthetic web graphics, so its tracking can be noisy for small, fast, or low-texture elements.
  2. Domain scope: The dataset focuses on CodePen web animations and doesn't cover specialized dynamic visuals like Manim mathematical animations or physics-based 3D simulations.

Future work could expand the benchmark to these broader domains and explore reinforcement learning (RL) to directly optimize models for visual and temporal fidelity rather than just code-level tokens.

Summary updated

BibTeX
@inproceedings{ji2026animation,
  author = {Anya Ji and Abhijith Varma Mudunuri and David M. Chan and Alane Suhr},
  title = {{Animation2Code: Evaluating Temporal Visual Reasoning in Video-to-Code Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=veADXfstkO},
}
Figure