Archive Duplicate Notion Database Items Automatically - n8n Workflow

Use this robust n8n workflow to automatically identify and archive redundant or duplicate pages in your Notion database based on specific property values. A powerful n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Notion power users needing automated database cleanup and data integrity maintenance.
Users looking for advanced examples of the n8n Code node for sophisticated data manipulation.
Automation specialists seeking reliable n8n templates for recurring maintenance tasks.
Anyone aiming to optimize their Notion workspace efficiency using a robust n8n workflow.

Overview

This sophisticated n8n workflow solves the common problem of data redundancy in Notion databases. Instead of manually reviewing thousands of entries, this automation runs on a set schedule or upon item creation, fetching all existing pages. It leverages a custom n8n node (the Code node) to perform efficient deduplication based on a user-defined property (like Title or URL). Once duplicates are identified (leaving one original copy untouched), the n8n workflow proceeds to archive them instantly. This prevents clutter, maintains data integrity, and is a fantastic example of what you can achieve with custom scripting inside an n8n node. This specific n8n template provides two convenient n8n trigger options: daily runs or triggering when a new page is added.

How it Works


  1. Trigger Initiation: The n8n workflow is started either by the "Every day" schedule n8n trigger or the "When a page is added" Notion n8n trigger.

  2. Data Retrieval: The Notion n8n node "Get pages from database" fetches all existing pages from the specified database.

  3. Property Mapping: The "Format items properly" Set n8n node standardizes the data structure, requiring the user to map the specific Notion property they wish to check for duplication (e.g., the Page Title) to the propertytocheck field.

  4. Data Consolidation: The "Aggregate all items" n8n node gathers all individual pages into a single data item array named pages, preparing it for processing in the next step.

  5. Deduplication Logic: The "Filter duplicates" Code n8n node executes custom JavaScript. It iterates through the aggregated list, identifies items where the propertytocheck value has already been encountered, and outputs only the second (and subsequent) duplicate items.

  6. Archiving: The final Notion n8n node, "Archive pages," uses the Page IDs supplied by the Code n8n node to archive (delete) the identified duplicate Notion pages. This reliable n8n workflow ensures only redundant items are removed.

Installation Guide


  1. Importing the n8n workflow: Copy the provided JSON content. In your n8n instance, click "+ New" and select "Import from JSON." Paste the data and save the n8n template.

  2. Notion Credential Setup: Ensure you have an active Notion credential configured in n8n and select it in the Notion nodes.

  3. Database Configuration: Edit the first Notion n8n node ("Get pages from database") and the Notion Trigger (if enabled) to select the correct Target Database ID using your Notion credential.

  4. Critical Property Mapping: Navigate to the "Format items properly" Set n8n node. In the assignment for propertytocheck, you must replace the placeholder "SET YOUR PROPERTY HERE" with the actual reference to the property you want to use for deduplication (e.g., the Page Title, a unique URL, or a text property). Use the n8n expression editor for accurate mapping.

  5. Activation: Once configured, ensure your chosen n8n trigger (Schedule or Notion Trigger) is active and enable the entire n8n workflow.

Node Details

Schedule Trigger / Notion Trigger: These n8n trigger nodes start the automation. You can choose to run this n8n workflow daily or whenever a new page is added to the Notion database.
Notion Node (Get pages from database): Fetches all items from the configured Notion database. Key configuration: operation: getAll, returnAll: true.
Set Node (Format items properly): A crucial preparation n8n node where the user configures the exact Notion property used for checking duplicates, mapping it to the propertytocheck field.
Aggregate Node (Aggregate all items): Combines all fetched items into one data array (pages), which is essential for list processing in the subsequent Code n8n node.
Code Node (Filter duplicates): The core logic of this n8n workflow. This custom n8n node uses efficient JavaScript logic to identify and output only the duplicate items based on the mapped property value, ensuring the first instance is always preserved.
Notion Node (Archive pages): The final action n8n node, responsible for archiving (effectively deleting) all incoming duplicate page IDs by setting the archived status to true in Notion.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

I'm a backend software developer who loves n8n ⚙️ I enjoy automating everything and share templates I personally find helpful 💡

Featured*