HTML to Video API

Turn HTML and CSS into videos

Send HTML and CSS with a list of actions. The API loads the page in headless Chrome, records it, and returns a hosted MP4, WebM, or GIF URL.

  • HTML, CSS & JavaScript
  • MP4, WebM & GIF
  • Set duration, frame rate, and size
Real API requests followed by their generated recordings.
Request
POST https://hcti.io/v1/recording
html
<main class="card">
  <p class="label">WEEKLY REPORT</p>
  <div class="row">
    <h1 id="count">12,480</h1>
    <span class="pill">▲ 18%</span>
  </div>
  <p class="caption">new signups this week</p>
  <div class="bars">
    <span style="--h:38%; --i:0"></span>
    <span style="--h:52%; --i:1"></span>
    <span style="--h:45%; --i:2"></span>
    <span style="--h:64%; --i:3"></span>
    <span style="--h:58%; --i:4"></span>
    <span style="--h:76%; --i:5"></span>
    <span style="--h:100%; --i:6"></span>
  </div>
</main>
css
* { box-sizing: border-box; }
body { margin: 0; background: #14151a; color: #f4f1ea; font-family: system-ui, sans-serif; }
.card { display: flex; flex-direction: column; height: 450px; padding: 40px 48px 0; }
.label { margin: 0; color: #8b8f9c; font-size: 13px; font-weight: 700; letter-spacing: 2px; }
.row { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
h1 { margin: 0; font-size: 84px; line-height: 1; letter-spacing: -3px; font-variant-numeric: tabular-nums; }
.pill { padding: 6px 12px; border-radius: 20px; background: #c8f169; color: #14151a; font-size: 18px; font-weight: 700; }
.caption { margin: 8px 0 0; color: #8b8f9c; font-size: 20px; }
.bars { flex: 1; display: flex; align-items: flex-end; gap: 14px; margin-top: 28px; }
.bars span { flex: 1; height: var(--h); border-radius: 6px 6px 0 0; background: #2f323d; transform-origin: bottom; }
.bars span:last-child { background: #c8f169; }

/* The action adds .recording to the body once capture starts.
   Without it, the preview shows the finished design. */
.recording .label, .recording .caption { animation: fade 500ms both; }
.recording .bars span { animation: grow 600ms cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 80ms); }
.recording .pill { animation: pop 400ms cubic-bezier(.2,1.4,.4,1) 700ms both; }

@keyframes fade { from { opacity: 0; } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
actions
[ { "type": "execute_javascript", "script": "document.body.classList.add(\u0027recording\u0027);\nconst el = document.getElementById(\u0027count\u0027), start = performance.now();\n(function tick(now) {\n const t = Math.min((now - start) / 1200, 1);\n el.textContent = Math.round(12480 * (1 - Math.pow(1 - t, 3))).toLocaleString(\u0027en-US\u0027);\n if (t \u003C 1) { requestAnimationFrame(tick); }\n})(start);", "timeout_ms": 1000 } ]
output format
gif
output scale
0.5
duration ms
3500
duration mode
fixed
device scale
1
viewport height
450
viewport width
800

Live demo

Try it with your own HTML

Edit this example or paste in your own HTML and CSS, then record it.

Loading playground…

HTML recording API

Send HTML and CSS, get a video URL

Recording begins once the page has loaded. Start your animation from the first action, so the first frame of the video is the first frame of the animation.

  • CSS and JavaScript animation

    Keyframes, transitions, and script-driven changes are recorded as Chrome renders them.

  • Starts on the first frame

    An execute_javascript action runs after capture begins. Use it to add the class that starts your animation.

  • MP4, WebM, or GIF

    Set output.format, and optionally output.fps and output.scale.

  • Hosted result

    The response has the recording_url, and a status_url to poll while it renders.

POST https://hcti.io/v1/recording request example.
Request
POST https://hcti.io/v1/recording
{
"html": "<h1>Version 2.0 is out.</h1>",
"css": "h1 { opacity: 0; } .recording h1 { animation: reveal 1s both; } @keyframes reveal { to { opacity: 1; } }",
"actions": [
{
"type": "execute_javascript",
"script": "document.body.classList.add('recording');"
}
],
"duration_ms": 5000,
"duration_mode": "fixed",
"viewport_width": 1280,
"viewport_height": 720,
"output": {
"format": "mp4"
}
}
200 OK Response
{
"id": "your-unique-recording-id",
"recording_url": "https://hcti.io/v1/recording/your-unique-recording-id.mp4",
"status_url": "https://hcti.io/v1/recordings/your-unique-recording-id/status"
}

Recording actions

Script what happens during the recording

Actions run in order while the page is recorded: scroll, click, run JavaScript, wait. A locate_selector action branches on whether an element is on the page.

actions: [ … ] Select an action to see its JSON
actions[0]

Click a button if it exists

if_found and if_not_found are each an array of actions. This clicks .show-details when it exists and moves on when it doesn't.

{
  "type": "locate_selector",
  "selector": ".show-details",
  "if_found": [
    { "type": "click", "selector": ".show-details" }
  ],
  "if_not_found": []
}

Use cases

What you can record

Try your own HTML

Product announcements

Animate a headline and feature list for a launch post, then export a GIF for the changelog.

Animated charts and counters

Draw a chart or counter from your data with JavaScript and record it as it animates.

UI demos

Record a transition or interaction once and embed the clip in docs, release notes, or email.

Personalized recaps

Turn a customer's activity, milestones, or results into a short, branded video using your HTML and CSS.

Output

MP4, WebM, or GIF

Set output.format. The HTML, CSS, and actions stay the same.

Which formats are supported?

MP4, WebM, and animated GIF. Recordings do not include audio. Video defaults to 30 FPS; GIF defaults to 15 FPS.

Can I make a smaller GIF?

Set output.scale to 0.5 to halve the exported width and height while keeping the same page layout. A shorter duration or a lower output.fps also makes the file smaller.

Can I record an existing website instead?

Yes. Send url instead of html. See the Scrolling Screenshots API, or try a URL in the scrolling screenshot tool.

Ready to record?

Record your first HTML animation

Paste HTML and CSS into the console, add an action, and get back an MP4, WebM, or GIF URL.