Programmable Media

JavaScript quick start

Last updated: Oct-31-2023

This quick start is intended to let you quickly try using several common Cloudinary features. It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.

You can perform this quick start in a code sandbox or in a clean project in the dev environment of your choice.

You can also view the completed code of this quick start in a GitHub repo and code explorer.

If you aren't familiar with Cloudinary, you may want to first take a look at the Developer get started guide for a high-level overview of integrating Cloudinary into your code, and an introduction to the main concepts.

You may also find our Glossary helpful to understand Cloudinary-specific terminology.

In this quick start you'll learn how to start delivering your media from Cloudinary using the @cloudinary/url-gen package.

This quick start assumes you are using pure JavaScript with a bundler, however you can also use the @cloudinary/url-gen package together with one of the frontend-frameworks packages. For details, see:

To get a more in-depth understanding of the architecture, you may want to start from the JavaScript SDK introduction.


To perform this quick start, you'll need:

1. Set up and configure the SDK

Install the package

Install the @cloudinary/url-gen package using the NPM package manager:

Configure Cloudinary

Create a basic JavaScript app, and in index.js copy and paste the following:


2. Upload an image

If you changed the cloud name in the previous step to your own, you need to use an image that's stored in your Cloudinary product environment for the next steps. All new accounts come with sample images, so you can use one of those, or, if you want to use the same image as us, save this image locally, then upload it to Cloudinary.

For convenience, the instruction below shows you how to manually upload files in the Cloudinary console UI, but as a developer, you'll probably be interested in uploading files programmatically. There are several ways to do this in client-side only applications, as explained in JavaScript SDK image and video upload or you can use the CLI.

For the purposes of this quick start, the quickest way to upload a single image is as follows:

  1. Log into your Cloudinary Console.
  2. Select Media Explorer from the left panel.
  3. Click Upload to open the Upload Widget, then click Advanced and type "docs/models" into the Public ID field.
  4. Click Browse to find the image to upload. Once uploaded, you can see the image in the listed assets (set Creation date to Today in the Search to find it quickly).

In the next step, you'll need the public ID of whichever image you use (in our case, we set the public ID on upload to docs/models). If using one of the sample images, you can copy the public ID from the Public ID column in the Media Explorer, when in list view:

Select and copy the public ID

3. Transform and deliver the image

Copy and paste this import statement below the existing one:

index.js (continued)

Copy and paste the following code, under the configuration code:

index.js (continued)

If you're using an image with a public ID other than docs/models, make sure to update your code with the public ID of the image you're delivering.

4. Run your code

Run the code to see the transformed image.

Transformed models image

View the completed code

Here's the full example:

This code is also available in GitHub.

Ready to learn more?
  • Understand the architecture of the JavaScript SDK and get a more detailed overview of the libraries.
  • Find out more about transforming images using @cloudinary/url-gen.
  • Learn about transforming videos using @cloudinary/url-gen.
  • Discover ways to improve load times and make your images responsive and accessible using plugins.

✔️ Feedback sent!

Rate this page: