How to Automate Video Generation with Node.js

14 May 2025 | 8 min read
Laura van Sinderen

In this tutorial, you'll learn how to create videos programmatically using Node.js (JavaScript) and Creatomate's video generation API.

If you've ever tried creating videos with JavaScript – especially in a Node.js environment – you've likely used FFmpeg (often through a wrapper like fluent-ffmpeg) or tools like Puppeteer for canvas-based rendering. These libraries work well for basic editing tasks, but they quickly hit limitations when it comes to more advanced video automation – such as generating social media content, personalized videos at scale, or integrating AI tools like ChatGPT, DALL·E, or ElevenLabs.

That's where Creatomate comes in: a flexible video generation API designed to make dynamic video creation simple. For example, you can easily generate faceless, AI-powered shorts complete with voiceovers, animated captions, and custom visuals. Creatomate integrates seamlessly with JavaScript-based Node.js projects, making it a powerful tool for developers working on automation workflows, content pipelines, or backend video services.

In this tutorial, I'll walk you through the core concepts of video automation using Node.js and Creatomate. It's a great starting point if you're looking to build your own video automation projects. At the end, I'll also link to follow-up tutorials that show how to take things further – like adding generative AI into your video workflow.

The example video we'll create here is just a glimpse of what's possible. From simple slideshows to complex, highly dynamic videos, Creatomate lets you automate nearly anything. Its online template editor gives you complete creative control, so you can customize every detail to match your style.

No matter what kind of video you're creating, let's dive in.

Prerequisites

Before you begin, make sure you have the following:

  • Node.js installed. If you haven't installed it yet, you can download it from the official Node.js website.
  • A Creatomate account. Sign up for a free account if you don't already have one.
  • A terminal or code editor. Any environment where you can run Node.js scripts will work.

How to create videos using Node.js?

There are two main ways to create videos using Node.js and Creatomate.

The simplest method is using a template. You design a video layout once, then reuse it in your script to insert dynamic data – generating a unique video each time. That's the approach we'll cover in this tutorial.

The second option is to build videos entirely in code, without using a predefined template. This gives you full control over every part of the video, from animations to timing. By writing a bit of JSON, you can define everything from start to finish – ideal for fully dynamic, data-driven videos. If that sounds interesting, check out the JSON to Video documentation.

Let's start by setting up a new Node.js project.

1. Set up your Node.js project

First, create a new folder for your project:

$ mkdir video_creation_project

Then, navigate into it:

$ cd video_creation_project

Next, initialize a new Node.js project:

$ npm init -y

For this tutorial, we'll use the built-in fetch API to communicate with the Creatomate API. This is available in Node.js version 18.0.0 and above. If you're using an older version, you'll need to update Node.js:

To check your current Node.js version, run:

$ node -v

If it's below 18.0.0, download and install the latest version from the Node.js website.

Now, create a JavaScript file where you'll write your code:

On macOS or Linux:

$ touch generate_video.js

On Windows:

$ echo. > generate_video.js

That's it for the setup! Your project is ready to go. In the next step, we'll design a video template in Creatomate that we'll use to generate our video.

2. Create a video template in Creatomate

Log in to your Creatomate account, or sign up for free if you haven't already.

Once you're in, head over to the Templates page and click New to open the template gallery. You can start from scratch if you already have a design in mind, or choose a pre-made template for a faster setup. For this tutorial, we'll keep it simple and use the Quick Promo template from the Featured category. Select the 9:16 Vertical format, then click Create Template to open it in the editor:

Now, let's take a quick look at how the template works.

On the left side of the editor, you'll find all the elements that make up the template. Some of them – like Video, Text-1, and Text-2 – are marked as dynamic. These are the parts you'll control through your Node.js script, allowing you to insert different text and media for each video you generate:

The editor gives you full flexibility to customize the template however you like. It's packed with powerful features and intuitive to use, especially if you've worked with video editors before. For a more detailed walkthrough, check out this quick guide.

Once your template is ready, you're all set to move on.

3. Generate the Node.js script

In this step, we'll turn our template into an API request.

Click the Use Template button in the top-right corner of the template editor, then select API Integration:

Creatomate will generate ready-to-use code snippets in various programming languages. Select Node.js, then copy the provided code:

Next, paste it into the empty generate_video.js file you created earlier.

4. Insert video content

Now, let's customize the content of your video using the “modifications” parameter.

This is where you define the text, media, and other dynamic elements for each render. You can pull this data from anywhere – APIs, databases, user input – but for now, we'll keep it simple with some predefined test values.

Copy and paste this into your script:

 const data = {
  "template_id": "your_template_id",
  "modifications": {
    "Video.source": "https://cdn.creatomate.com/demo/video5.mp4",
    "Text-1.text": "Hello Node.js users 👋",
    "Text-2.text": "It's easy to create videos from your own scripts!"
  }
};

Note: Be sure to replace “your_template_id” with the actual ID of the template you created in step 2. This tells the API exactly which design to use.

5. Run the script to create a video

With your script ready, it's time to run it:

$ node generate_video.js

After the API call is made, Creatomate will respond with a JSON array confirming that your request was received:

1[
2  {
3    "id": "417dd577-f53c-4faa-9954-892a9b0cbb3e",
4    "status": "planned",
5    "url": "https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/417dd577-f53c-4faa-9954-892a9b0cbb3e.mp4",
6    "snapshot_url": "https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/417dd577-f53c-4faa-9954-892a9b0cbb3e-snapshot.jpg",
7    ...
8  }
9]

At this point, the video is being rendered in the background.

There are two ways to wait for the video to complete.

One option is to write a small JavaScript function that checks if the "status" has changed to "succeeded". This approach requires making a separate GET request to retrieve the video's status.

The second, and recommended, approach is to use a webhook. With this method, Creatomate sends a notification (a reverse API call) to your application as soon as the video is ready.

For now, just wait about a minute, then visit the URL returned in the API response. If you see a "Not Found" message, the video is still rendering – just give it a little more time and try again.

Once it's done, the URL will show your finished video:

Now that you have the video URL, you can do whatever you need – download it, embed it, or plug it straight into your automation pipeline.

Tip: You can view all your API requests on the API Log page in your Creatomate dashboard. If a video fails to render, you'll find the error message and suggested fixes there.

What's next for video creation with Node.js

And that's how you can create videos using Node.js and Creatomate. Now that you understand the basics, you can adapt this workflow to suit your own use cases.

Want to build AI-generated videos? Think about the faceless shorts you see on YouTube, TikTok, or Instagram. With Node.js, you can create a fully automated pipeline using AI tools. For example, you can use ChatGPT to generate a script based on a topic or keyword. Then, turn that script into a voiceover with a text-to-speech API like ElevenLabs. Use Creatomate to add animated captions using its auto-transcription feature, synced word-by-word just like the trending styles. For visuals, create images with DALL·E, Stable Diffusion, or other AI image-generation tools. To make posting even easier, let ChatGPT generate captions and hashtags for your social media content. All of this is possible in Node.js by combining these APIs into a single automated workflow.

Here are some helpful tutorials and examples. While they aren't Node-specific, the concepts are easily adaptable to your JavaScript environment.

👉 How to Create AI Voice Over Videos using an API
👉 Using ChatGPT's API to Auto-Create Social Media Videos by Code
👉 How to Automate AI-Generated Shorts, Stories, and Reels

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free