Programmable Media

Node.js SDK

Last updated: May-29-2024

This page provides an in-depth introduction to the Node.js SDK.

If you're ready to get coding, jump straight to our quick start.
Cloudinary Academy


We invite you to try the free Introduction to Cloudinary for Node.js Developers online course, where you can learn how to upload, manage, transform and optimize your digital assets.


Cloudinary's Node.js SDK provides simple, yet comprehensive image and video upload, transformation, optimization, and delivery capabilities that you can implement using code that integrates seamlessly with your existing Node.js application.

Related topics

This guide relates to the latest released version of the Cloudinary Node.js library.

  • For details on all new features and fixes from previous versions, see the CHANGELOG.
  • The latest version of the SDK supports Node.js v9 and up.
  • By default, URLs generated with this SDK include an appended SDK-usage query parameter. Cloudinary tracks aggregated data from this parameter to improve future SDK versions and no individual data is collected. If needed, you can disable the analytics configuration option. Learn more.

Quick example: Transformations

Take a look at the following transformation code and the image it delivers:

sample transformation

This relatively simple code performs all of the following on the original front_face.jpg image before delivering it:

  • Crop to a 150x150 thumbnail using face-detection gravity to automatically determine the location for the crop
  • Round the corners with a 20 pixel radius
  • Apply a sepia effect
  • Overlay the Cloudinary logo on the southeast corner of the image (with a slight offset). The logo is scaled down to a 50 pixel width, with increased brightness and partial transparency (opacity = 60%)
  • Rotate the resulting image (including the overlay) by 10 degrees
  • Convert and deliver the image in PNG format (the originally uploaded image was a JPG)

And here's the URL that would be included in the image tag that's automatically generated from the above code:

In a similar way, you can transform a video.

Learn more about transformations

Quick example: File upload

The following Node.js code uploads the dog.mp4 video using the public_id, my_dog. The video will overwrite the existing my_dog video if it exists. When the video upload is complete, the specified notification URL will receive details about the uploaded media asset.

Node.js SDK features

Node.js SDK installation and configuration video tutorial

Watch this video tutorial to see how to install and configure the Node.js SDK:

Installation and setup

Cloudinary's Node.js integration library is available as an open-source NPM. To install the Cloudinary NPM, run:

Include Cloudinary's Node.js classes in your code:

The Node.js SDK upload and admin method syntax examples shown throughout this documentation use the v2 signature. To avoid confusion, all code examples are shown in the format cloudinary.v2....

In your own code, it is recommended to include v2 of the Node.js classes as follows:

Alternatively, from within a module, you can use an ES6 import statement:

Following either of these, your upload and Admin API calls should omit the .v2 shown in the code examples of this guide.
For example, a simple image upload:


To use the Cloudinary Node.js library, you have to configure at least your cloud_name. An api_key and api_secret are also needed for secure API calls to Cloudinary (e.g., image and video uploads). You can find your product environment configuration credentials in the API Keys page of the Cloudinary Console.

In addition to the required configuration parameters, you can define a number of optional configuration parameters if relevant.

Setting the configuration parameters can be done globally, using either an environment variable or the config method, or programmatically in each call to a Cloudinary method. Parameters set in a call to a Cloudinary method override globally set parameters.

Setting the CLOUDINARY_URL environment variable

You can configure the required cloud_name, api_key, and api_secret by defining the CLOUDINARY_URL environment variable. Copy the API environment variable format from the API Keys page of the Cloudinary Console Settings. Replace <your_api_key> and <your_api_secret> with your actual values, while your cloud name is already correctly included in the format. When using Cloudinary through a PaaS add-on (e.g., Heroku or AppFog), this environment variable is automatically defined in your deployment environment. For example:

Set additional parameters, for example upload_prefix and secure_distribution, to the environment variable:

Setting configuration parameters globally

Here's an example of setting configuration parameters globally in your Node application:

Node.js capitalization and data type guidelines

When using the Node.js SDK, keep these guidelines in mind:

  • Parameter names: snake_case. For example: public_id
  • Classes: PascalCase. For example: PreloadedFile
  • Methods: snake_case. For example: image_upload_tag
  • Pass parameter data as: Object

Sample projects

For additional useful code samples and to learn how to integrate Cloudinary with your Node.js applications, take a look at our Sample Projects.

  • Basic Node.js sample: Uploading local and remote images to Cloudinary and generating various transformation URLs.
  • Node.js Photo Album: A fully working web application that allows you to upload photos, maintain a database with references, list images with their metadata, and display them using various cloud-based transformations. Image uploading is performed both from the server side and directly from the browser using a jQuery plugin.

Related topics

✔️ Feedback sent!

Rate this page: