I keep ending up with an animation that looks right in the browser — a CSS title card, a GSAP chart, a canvas loop, or a page an assistant just wrote — and then I need an HTML to video file. The README wants a GIF. The slide deck wants an MP4. A social post wants a vertical clip. Getting from a live tab to that file is the part I used to improvise, and the improvisation showed.
Screen recordings picked up my cursor and the size of the window. When the machine got busy, frames dropped. A headless-browser and FFmpeg pipeline can do this well, but it is a project of its own when I only need a twelve-second clip. I wanted a routine I could repeat without installing a stack, assuming I already had an animation that runs in a web page, whether I wrote it or an assistant did.
Make the page export-ready first
Most failed exports I have seen were not encoder problems. The page was waiting for a click, a hover, or a scroll that never comes. A font or an image was loaded from a host that blocks other sites from reading it, so the asset vanished in the rendered frames. Or the motion lived in SMIL tags on an SVG, which this kind of capture does not pick up. Embedded videos, audio elements, and iframes are left out too.
Before you paste anything, get the page into a shape that can play by itself:
- It fills the frame and does not scroll. Sizing in
vwandvhscales more cleanly than leftover desktop pixels. - It starts on load. No "click to play," no hover reveal, no scroll-triggered scene.
- It has a fixed length. A first-line comment such as
<!-- duration: 8s -->makes that length obvious. - CSS, JavaScript, and images travel with the page: styles and scripts inline, images as inline SVG or data URLs. Fonts and libraries should come only from a CDN that allows cross-origin loading, such as Google Fonts, cdnjs, or jsDelivr.
- The motion uses CSS animations or transitions, the Web Animations API, GSAP, anime.js, Motion, Canvas 2D, SVG animated with CSS or JavaScript, WebGL or Three.js, or
requestAnimationFramewith its timestamp argument. Pages that draw each frame withwindow.seek(t)are also in scope.
If the HTML came out of a chat, I do not paste the first draft blindly. I add a short rewrite request so the assistant returns one self-contained file. This is the wording I use, taken from the converter's own homepage:
Rewrite this animation as one self-contained HTML file that I can export to video with htmlto.video: - Design it for a 16:9 frame. It must fill the browser window exactly (100vw by 100vh, no scrolling). Size everything in vw and vh so it scales to any resolution. - It starts by itself when the page loads and needs no mouse, keyboard or scrolling. - It has a fixed length. State the length in a comment on the first line, like <!-- duration: 8s -->. - Animate with CSS animations, the Web Animations API, GSAP, or requestAnimationFrame using its timestamp argument. Do not use video, audio or iframes. - Put all CSS and JavaScript inline. Embed images as inline SVG or data URLs. Fonts and libraries may only come from a CDN that allows cross-origin loading, such as Google Fonts, cdnjs or jsDelivr. - Reply with the complete HTML in a single code block. For 9:16, 1:1, or 4:5, change the frame in that prompt. You still want one file, a known duration, and motion that starts on its own.
Paste, check the preview, then pick a frame
Once the HTML can run unattended, the mechanical part is short. Paste the markup, or drop an .html or .zip file, into a browser-based HTML to video converter. The preview starts right away. Choose the aspect ratio for where the file will be used: 16:9 for decks and most wide posts, 9:16 for vertical clips, 1:1 or 4:5 when the destination is square-ish. The duration is read from the animation, and you can shorten it.
Keep that tab in front while it renders. Exporting works in Chrome, Edge, and Firefox on a desktop, and in Chrome on Android. Safari, iPhone, and iPad can show the preview but cannot export. If you are on those, open the same page in a supported desktop browser before you assume the HTML is broken.
Choosing a format for the HTML to video file
The remaining choice is the format:
- MP4 for social posts, slides, and editors. It is H.264 at 720p, 1080p, or 4K, and 24, 30, or 60 frames per second.
- GIF for READMEs, docs, chat, and email. It loops without a player. Keep it short: the cap is 30 seconds, and 360p, 480p, or 720p at 10, 15, or 25 fps is plenty for a loop.
- Transparent WebM when you want a title, a lower third, or a sticker over a video in an editor. Leave the page background unset so the alpha channel stays see-through.
- A PNG frame when you only need a still for a thumbnail or a cover, captured at the moment you choose.
A clip can be up to 120 seconds for video, or 30 seconds for a GIF. There is no account, no watermark, and no fee, including for commercial work. Rendering happens frame by frame in the browser, so the file is never uploaded, and the frame rate stays exact even if the computer is busy. For music or a voiceover on an MP4 or WebM, add an MP3, M4A, WAV, or OGG file before you export. The audio is cut to the video's length and fades out if the track runs longer. Sound the page plays by itself is not recorded, and GIF and PNG have no sound.
The converter's own page says a typical 10-second clip at 1080p and 60 fps takes about 20 to 40 seconds to render. Heavier WebGL and 4K take longer, and very heavy WebGL can fail on a slower machine.
To convert HTML animation to MP4 at a set size and frame rate, set 1080p or 4K and 24, 30, or 60 fps, then export.
When the preview looks wrong
If a font or image is missing, the host almost certainly blocked cross-origin reading. Embed the asset as a data URL or inline SVG, or switch to a font host that allows the read. If nothing moves, the animation is probably waiting for input — take the interaction out and let it run on load. If you used SMIL (<animate> and similar tags), rewrite the motion in CSS or JavaScript. If a frame cannot be drawn, simplify the WebGL, or remove an embedded video or iframe.
That is the whole loop: fix the page so it can play unattended, paste it, check the ratio and length, and export in the format the destination actually needs. I still use a headless-browser pipeline for clips longer than two minutes, or for CI.
Disclosure: I work on the converter linked in this article. The limits, supported APIs, and failure cases above are the ones it documents.
This post was drafted with AI assistance and reviewed before publishing.