This script identifies unlinked assets in a Contentful space by scanning entries and checking for assets that are not referenced.
- 🖥️ Node.js (latest LTS version recommended)
- 🔑 A Contentful API key with read access
- 📄 A
.env
file with Contentful credentials
-
Clone this repository:
git clone <repository-url> cd <repository-name>
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add your Contentful credentials:CONTENTFUL_SPACE_ID=your_space_id CONTENTFUL_ENVIRONMENT_ID=master CONTENTFUL_ACCESS_TOKEN=your_access_token
For reference, users can look at the 📂 env sample file for the required format and variables.
To execute the script and generate the list of unlinked assets:
node find-unlinked-assets.js
The output will be saved to a file named unlinked-assets.json
in the project root as well as a console output.
An example output file can be found here:
📂 Example Unlinked Assets Output
- ⏳ Large spaces may take longer to process.
- 🌍 Make sure your API key has access to the space and environment in Contentful
This script is provided as-is and is not supported by Contentful. Use at your own discretion.
📝 MIT License