JavaScript quick start

Last updated: Nov-14-2022

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 the steps in 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:

Copy to clipboard
npm i @cloudinary/url-gen

Configure Cloudinary

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


Copy to clipboard
// Import the Cloudinary class.
import {Cloudinary} from "@cloudinary/url-gen";

// Create a Cloudinary instance and set your cloud name.
const cld = new Cloudinary({
  cloud: {
    cloudName: 'demo'

2. Transform and deliver an image

This step assumes that you have assets already uploaded to Cloudinary. To upload files, see JavaScript SDK image and video upload. Additionally, you can use the CLI to upload files programmatically, or log into your Media Library to upload files manually.

Copy and paste this import statement below the existing one:

index.js (continued)

Copy to clipboard
// Import any actions required for transformations.
import {fill} from "@cloudinary/url-gen/actions/resize";

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

index.js (continued)

Copy to clipboard
// Instantiate a CloudinaryImage object for the image with the public ID, 'docs/models'.
const myImage = cld.image('docs/models'); 

// Resize to 250 x 250 pixels using the 'fill' crop mode.

// Render the image in an 'img' element.
const imgElement = document.createElement('img');
imgElement.src = myImage.toURL();

If you're using your own cloud name, rather than demo, then you need to change docs/models to the public ID of an image you've already uploaded to Cloudinary.

3. 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: