Craftshift logo

How to delete files in Shopify: the complete cleanup guide

how to delete files shopify

The Files area in your Shopify admin.Scrolling through can take ages especially if you have a large store and it’s been around for more than a year, you could be looking at thousands of PNGs, JPGs, PDFs and fonts. As well as the occasional .glb 3D model that you uploaded at some point and completely forgot about. Many of these files will not be linked to anywhere in your store and currently you have no real way of identifying this.

This is the post I wish I had before I started diving into cleaning up a client store This post will explain where Shopify actually stores files, how to find the Orphans, step through deleting one at a time (useful for small numbers of files) ,step through bulk deleting via the Admin API (for thousands of files) , and explain the Storage Limits by plan. Spoiler alert: Shopify is actually more generous with storage limits than you might expect.

– Never mass delete files on a live store unless you have a backup list of files you are going to need to reupload later (I once mass deleted 1,000 files on a Friday night and spent half of Monday re-uploading one missing logo file that was used in a blog post from 2012). Export first. Delete second.

In this post

Where Shopify actually stores files

Shopify uses 3 different surfaces to store files and it confuses everyone. The Files area (Content > Files) is for general storage of anything you might drag and drop. So if you upload an image in the blog editor, or reference a PDF in a metafield, the Shopify app will store it in the Files area. Even the images you upload in the product editor don’t store there: they’re stored with the product itself (Products > [product] > Media). But then there are the theme assets: the JPGs and PNGs your theme’s liquid references directly. These are stored under Online Store > Themes > Actions > Edit code > assets folder.

Why delete files from your site matter – “delete files” means something entirely different to me depending on what area of the site I am in. A product image I uploaded and published to the Files area might still be attached to a product. A theme asset I published to the Files area will now break my theme if it is referenced in liquid. Three places in one site to follow different rules.

Finding files and spotting orphans

Files has filters. Sort, type, and search by filename. Many miss the references column. If you click on a file and it shows nothing is referencing it, that means it is an orphaned file. Safe to delete.

Shopify doesn’t give you a way to view all the orphans in one shot, either it’s something you manually go through when you have 50 files to fix up, or you hit the API for 5000 files.

Deleting one file at a time

For small cleanups this is fine. Select the file, click Delete, confirm. The file gets deleted from your CDN and no longer counts against your storage. Be aware that any references to the file in metafields will get broken, so double check before you delete anything.

  1. Go to Content > Files in the admin.
  2. Hover the file and click the checkbox on the left.
  3. Click Delete files in the top bar.
  4. Confirm. Gone.

You can select more than one file per page. In fact you can select up to 50 files per page. There is a checkbox at the top of the page that you can check to select all of the files on the page. This is basically your “bulk delete” option. It’s slow if you have thousands of files, but it does work.

Bulk delete via the Admin API

With Shopify’s new GraphQL Admin API it’s now trivial to delete all unwanted theme files. The function fileDelete accepts a list of file IDs as an argument, meaning you can delete many files at the same time. All you need is the function fileDelete, and the api call to retrieve all available files including pagination from the files query. Deleting all your theme files in various Store implementations in less than 20 lines of code written in Node or Python, is definitely fun and powerful.

Rough shape of the workflow. Query files(first: 250) with a cursor. Walk the pages. For each file, check the references edge count. If zero, add the ID to a delete batch. Run fileDelete(fileIds: […]) in chunks of 100. Respect the rate limits. Shopify throttles you hard if you don’t. Log every deletion so you can recover if something breaks.

This sounds really really really dangerous, but apparently not as dangerous as manually going through 3000 checkboxes one by one, which I have to do now because WordPress won’t delete a plugin for me. Found this method online, it took me 40 minutes to do 12,000 files on a huge merchant’s store, but they all came back safe and sound, and it even recovered 18GB of storage space! Of course I had previously exported everything and backed it up on a safe location before attempting this, don’t try this on anything you haven’t previously saved safely!

Storage limits per plan

// shops on Shopify don’t have a capped amount of storage space for files and media. In fact, as long as you’re on a paid Shopify plan (Basic, Online Store, Professional, Unlimited, or Plus), your file storage is effectively unlimited, aside from fair-use guidelines. This means you can always host more graphics, blog entries, pages and add-ons, and unless you’re somehow abusing your space (e.g. loading up a bunch of pirated movies), you’re unlikely to ever hear from Shopify about your storage levels.

PlanFile storageMax product image size
BasicUnlimited (fair use)20 MB
ShopifyUnlimited (fair use)20 MB
AdvancedUnlimited (fair use)20 MB
PlusUnlimited (fair use)20 MB

So why bother doing this? Why not just let the files all sit there and grow and grow? Three main reasons really. One, admin performance: the Files area becomes very slow to browse past 10,000 files. Two, organization: as the number of files grows, it becomes harder and harder to find lost files. Three, the cost of the way things are now rises with any future migration, theme update, or audit. I don’t want a store that’s slow and hard to use.

A sane cleanup workflow

Here’s the workflow I actually run on client stores. Five steps.

  1. Export first. Use the Shopify product image downloader to grab every product image as a ZIP before you touch anything.
  2. Audit products. Delete unused products first. Orphaned product images vanish with them. Our Bulk Delete Products app does this with filters.
  3. Sort Files by date. Oldest first. Anything uploaded during a campaign that ended 18 months ago is probably safe.
  4. Check references. Click any file you’re unsure about. No references, safe to delete.
  5. Bulk delete the confirmed orphans. Either in the admin 50 at a time, or via API for thousands.

Theme assets referenced in liquid do not appear as files in the Files section of the theme. This is why deleting files in the Files section can often break your site, because you will have deleted a duplicate of an asset actually referenced in the theme, and then something else will fail for unknown reasons. Lesson learned.

Variant image cleanup is a different beast

Variant images are another common source of file bloat. Many stores end up with several sets of images per color, and Shopify caps each product at 250 images. Cleaning these manually is tedious. Rubik Variant Images helps surface duplicate and unused images on each product. For stores running into the 250 image cap, Rubik Combined Listings groups separate products as color variants so each product carries its own 250 image budget.

Rubik Variant Images Shopify App Store listing

“This app makes it easy to hide non-variant product photos and keeps the product page looking clean. It also helps to show clean custom swatches. Their customer support is outstanding and they reply almost immediately.”

Shopify merchant, Rubik Variant Images review

Want a live demo first? There’s a live demo on Rubik Variant Images, a full tutorial on the video above, and the docs on all the assignment modes. You can also try it out for free with unlimited products for 14 days. The free plan includes support for 1 product only before upgrading to a paid plan.

Shopify limits products to 2048 variants total (with Combined Listings), no matter how you get there, and up to 3 option types. This has nothing to do with file storage, but a lot of merchants mistake the problem of storing unused files for the problem of removing unused product variants. See the 2048 variant limit explained for more info on the variant limit.

Clean images, clean catalog

Frequently asked questions

Does deleting a file free up space on my Shopify plan?

Technically yes, but we have unlimited file storage on all Shopify plans under fair use. You won’t reach a file storage limit. I’m removing the file storage limit aspect from the checklist as you effectively have unlimited storage on all Shopify plans. The checklist items around deleting products and images are more about helping you organize your store and bring down the number of items your admin and your staff need to review on a daily basis. CF

Will deleting a file break my theme?

Except for direct references in liquid code or hard coded settings in sections that are unreferenced in Content > Files, these files are a security risk and should be deleted. Theme assets are stored in the theme’s /Online Store/Themes/Theme Name/Edit code folder.

Can I recover a deleted Shopify file?

– This field is used for permanent deletion, not delete from database but delete from index. There’s no trash or recycle bin, so always export any fields you intend to bulk delete before doing the deletion.

How do I bulk delete files in Shopify?

Native admin Interface allows you to select up to 50 files per page to delete from check boxes on the page and mass delete them at once. For thousands of files, use GraphQL Admin API – fileDelete mutation with pagination.

Does Shopify have a file storage limit?

All paid plans include unlimited file storage under a fair-use policy. Individual product images are allowed up to 20 MB each.

How do I find unused files in Shopify?

Click on any file in Content > Files and look at the references panel on the right. If it says zero references, then that file is an orphan and can be safely deleted.

Our Shopify Apps

Smart Bulk Image Upload

Bulk upload product images from Google Drive & save time!

Rubik Variant Image & Swatch

Show only relevant variant images on your product pages.

Rubik Combined Listings Swatch app

Rubik Combined Listings

Link separate products as variants with beautiful swatches

CS – Export Product Images

Bulk export product images by vendor, collection or status

Blog Posts