How to download a gif from Giphy

Recently, when I was trying to download a gif file from Giphy, I noticed that when I went directly to the file, https://media.giphy.com/media/14kdiJUblbWBXy/giphy.gif for example, that it was actually loading a web page instead of the gif file. 😞

Now, on this page, you could choose to alternative/right click on the image and then click “Save Image”. But, this will download the image with a .webp extension. From there, you can choose to change the extension to .gif if you’d like. But, I’ll be honest and tell you that I didn’t consider switching the extension at first. So, I dug further.

I figured that Giphy was probably detecting that based on who/where the request was coming from, so I tried downloading the gif file by running a cURL command. This worked, but it’s not convenient to have to open up a terminal window to run a cURL command.

Luckily, a kind person left a very helpful comment below with an even simpler approach, which I think is the simplest approach overall.

Simple approach

When we go to a standard Giphy source URL, like https://media.giphy.com/media/14kdiJUblbWBXy/giphy.gif, a web page is loaded instead of the gif that we want. Now, the only thing we have to change for the actual gif to load is to change media.giphy.com to i.giphy.com.

So, if we take the above example, we could load the actual gif by going to https://i.giphy.com/media/14kdiJUblbWBXy/giphy.gif

From here, we can alternate/right click to download the gif with the correct extension and go on about our day.

Downloading via cURL

curl https://media.giphy.com/media/KXgJsSeOfvSgg/giphy.gif --output ~/Desktop/download.gif

This resulted in the actual gif file that I wanted being placed on my Desktop as download.gif. 💪