Skip to main content

How to add a special characters in text overlays?



  • Salil Sethi

    when I double escape the following string and send it over


    "The arrangement covers the movie studio 20th Century Fox, the company’s TV production arm 20th Century Fox Television, Fox-owned cable networks (including FX and National Geographic), and the company’s stakes in international networks like Star TV and Sky (which Fox is planning to acquire full ownership of before" 

    I'm receiving the following image with encoding characters

  • Roee Ben Ari

    Hi Salil,

    In order to get a valid URL, please use encodeURIComponent instead of escape, like this:

    overlayText = encodeURIComponent(encodeURIComponent(text));

    You can read more about the difference between the two methods here:


  • Lowell Chayadi

    hello, how about % character, I tried double-escape for that, but the node js library state that it's failing to decode URI malformed

  • Raya Straus

    Hi Lowell,

    Can you please share with us your implementation? 

  • Catherine Seo

    hello, I am having trouble getting commas to show up on text overlay. Here is a snippet of my code.




    overlay: {

      font_family: 'arial',

      font_size: 14,

      text_align: 'left',

      text: 'WALK, HIKE, RUN, RIDE',





    I have tried

    1. encodeURIComponent('WALK, HIKE, RUN, RIDE')

    2. encodeURIComponent(encodeURIComponent('WALK, HIKE, RUN, RIDE'))

    3. ‘WALK\\, HIKE\\, RUN\\, RIDE’


    but none of these seem to work and I get the encoded string on my generated image. Can you please assist? Thank you!

  • Tia Esguerra

    Hi Catherine, 

    Thanks for reaching out.

    In the Node SDK, the cloudinary.url() helper method will handle the encoding for you. For example:

    let url = cloudinary.url("sample.jpg", {
    	transformation: [
    			color: "#000000",
    			overlay: {
    				font_family: "Arial",
    				font_size: 32,
    				text: "WALK, HIKE, RUN, RIDE",
    		{ flags: "layer_apply", gravity: "center" },

    The code block above generates this URL:,l_text:Arial_32:WALK%252C%20HIKE%252C%20RUN%252C%20RIDE/fl_layer_apply,g_center/v1632156908/sample.jpg

    Can you give this a try and let me know how it goes?

    Kind regards, 


  • Catherine Seo

    Hi Tia!

    Thank you for your response. So I am actually running this transformation in a serverless environment (from a lambda function) and I found that I could not call the `.url` method, without getting an error (from the cloudinary sdk) about not being able to find `./package.json`. It was this line specifically ( that was throwing the error. I'm thinking it's possibly related to `fs` in a lambda that's causing the issue? But `await cloudinary.uploader.upload(….)` works just fine so that is where I've been calling the transformations from. Does `.upload` not encode the text that gets passed into the transformations?

    Thank you!


  • Danny Valentine

    Hi Catherine. Thanks for the additional information

    I'm not super familiar with AWS personally, but it's possible that the environment available to you is missing certain packages that we assume are there, which are usually present in a default Node installation. This in turn leads to errors when we attempt to use the .url() helper method.

    I assume everything works fine for you locally, and only fails when part of a Lambda, but could you please confirm? It would also be helpful if you could provide us with the full error message you get, if at all possible. If you would prefer to raise a support ticket instead due to the potential for sensitive details to be shared, you would be welcome to do so via

    Many thanks,


Please sign in to leave a comment.