saroroce

payload extended import export plugin

by saroroce
Import, export & migration
v3
^3.37.0

Overview

Summary generated from the README

Extends the Payload import-export idea with an Import button in the list view of chosen collections. A drawer guides editors through file upload, data preview, column-to-field mapping, validation and import with progress tracking. It also exposes a POST import endpoint and requires Payload 3.37 or newer.

Features

  • Import button added to the list view of selected collections
  • Supports CSV, JSON, Excel (.xlsx) and TSV files
  • Visual mapping of file columns to collection fields
  • Data preview and validation before import
  • Real-time import progress and error messages
  • Sample file generation and localization support

Use cases

  • Bulk load posts or pages from spreadsheets into a Payload collection
  • Migrate user records from a CSV export into Payload
  • Let editors map and validate uploaded data before it is written

From the author

This is an extended version of the Payload CMS import-export plugin, providing additional features and enhancements.

Installation

npm i payload-extended-import-export-plugin

31

Stars

7

Forks

1

Open Issues

1 years ago

Last Updated

26

Weekly Downloads

v1.0.11

npm Version

380.0 KB

Unpacked Size

3

Dependencies

GitHub stars

31+2 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202631
Dec 5, 202631
Dec 4, 202631
Dec 3, 202631
Dec 2, 202631
Dec 1, 202631
Nov 30, 202631
Nov 29, 202631
Nov 28, 202631
Nov 27, 202631
Nov 26, 202631
Nov 25, 202631
Nov 24, 202631
Nov 23, 202631
Nov 22, 202630
Nov 21, 202630
Nov 20, 202630
Nov 19, 202630
Nov 18, 202630
Nov 17, 202630
Nov 16, 202630
Nov 15, 202630
Nov 14, 202630
Nov 13, 202630
Nov 12, 202630
Nov 11, 202630
Nov 10, 202630
Nov 9, 202630
Nov 8, 202630
Nov 7, 202630
Nov 6, 202630
Nov 5, 202630
Nov 4, 202629
Nov 3, 202629
Nov 2, 202629
Nov 1, 202629
Oct 31, 202629
Oct 30, 202629
Oct 29, 202629
Oct 28, 202629
Oct 27, 202629
Oct 26, 202629
Oct 25, 202629
Oct 24, 202629
Oct 23, 202629
Oct 22, 202629
Oct 21, 202629
Oct 20, 202629
Oct 19, 202629
Oct 18, 202629
Oct 17, 202629
Oct 16, 202629
Oct 15, 202629
Oct 14, 202629
Oct 13, 202629
Oct 12, 202629
Oct 11, 202629
Oct 10, 202629
Oct 9, 202629
Oct 8, 202629
Oct 7, 202629
Oct 6, 202629
Oct 5, 202629
Oct 4, 202629
Oct 3, 202629
Oct 2, 202629
Oct 1, 202629
Sep 30, 202629
Sep 29, 202629
Sep 28, 202629
Sep 27, 202629
Sep 26, 202629
Sep 25, 202629
Sep 24, 202629
Sep 23, 202629
Sep 22, 202629
Sep 21, 202629
Sep 20, 202629
Sep 19, 202629
Sep 18, 202629
Sep 17, 202629
Sep 16, 202629
Sep 15, 202629
Sep 14, 202629
Sep 13, 202629
Sep 12, 202629
Sep 11, 202629
Sep 10, 202629
Sep 9, 202629
Sep 8, 202629
Sep 7, 202629
npm weekly downloads

27+17 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202627
Dec 5, 202627
Dec 4, 20263
Dec 3, 20262
Dec 2, 20262
Dec 1, 20263
Nov 30, 20263
Nov 29, 202615
Nov 28, 202615
Nov 27, 202615
Nov 26, 202615
Nov 25, 202615
Nov 24, 202614
Nov 23, 202614
Nov 22, 20263
Nov 21, 20264
Nov 20, 20264
Nov 19, 20265
Nov 18, 202616
Nov 17, 202616
Nov 16, 202617
Nov 15, 202615
Nov 14, 202615
Nov 13, 202617
Nov 12, 202628
Nov 11, 202617
Nov 10, 202620
Nov 9, 202619
Nov 8, 202620
Nov 7, 202619
Nov 6, 202616
Nov 5, 20264
Nov 4, 20264
Nov 3, 20261
Nov 2, 20264
Nov 1, 20263
Oct 31, 20264
Oct 30, 20264
Oct 29, 20264
Oct 28, 20264
Oct 27, 20266
Oct 26, 20263
Oct 25, 20264
Oct 24, 20264
Oct 23, 20264
Oct 22, 20266
Oct 21, 20266
Oct 20, 20264
Oct 19, 20264
Oct 18, 20263
Oct 17, 20263
Oct 16, 20263
Oct 15, 20262
Oct 14, 202613
Oct 13, 202614
Oct 12, 202614
Oct 11, 202615
Oct 10, 202615
Oct 9, 202615
Oct 8, 202614
Oct 7, 20264
Oct 6, 20263
Oct 5, 20264
Oct 4, 20263
Oct 3, 20263
Oct 2, 20263
Oct 1, 20263
Sep 30, 20262
Sep 29, 202614
Sep 28, 202613
Sep 27, 202614
Sep 26, 202616
Sep 25, 202616
Sep 24, 202617
Sep 23, 202617
Sep 22, 202617
Sep 21, 202617
Sep 20, 202617
Sep 19, 202615
Sep 18, 202615
Sep 17, 202617
Sep 16, 202618
Sep 15, 20266
Sep 14, 20268
Sep 13, 20268
Sep 12, 202610
Sep 11, 202610
Sep 10, 20267
Sep 9, 20267
Sep 8, 202610
Sep 7, 202610

Each point is npm's rolling 7-day download count.

Health Score

35/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1030244052-root.svg)](https://payloaddirectory.dev/plugins/1030244052-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1030244052-root"><img src="https://payloaddirectory.dev/badge/1030244052-root.svg" alt="Payload Directory"></a>
Updated Aug 6, 2025Created Aug 1, 2025Published Aug 6, 2025

README

Payload Extended Import Export Plugin

An extended import and export plugin for Payload CMS with additional features and enhancements.

Features

  • 📤 Data Import - Import data from CSV, JSON and other formats
  • 🔧 Field Mapping Configuration - Flexible field mapping during import
  • 📊 Data Preview - Preview data before importing
  • ⚡ Import Progress - Track import progress in real-time
  • 🎯 Selective Import - Choose specific collections to import
  • 🌐 Localization Support - Work with multilingual data
  • 🔍 Data Validation - Validate data before import
  • 📁 Sample Files - Generate sample files for import

Installation

Install the plugin via npm or pnpm:

npm i payload-extended-import-export-plugin

or

pnpm add payload-extended-import-export-plugin

Usage

Add the plugin to your payload.config.ts:

import { payloadExtendedImportExportPlugin } from 'payload-extended-import-export-plugin'

export default buildConfig({
  plugins: [
    payloadExtendedImportExportPlugin({
      collections: ['posts', 'users', 'pages'], // Specify collections for import
      enabled: true,
    }),
  ],
})

Configuration Options

The plugin accepts the following configuration options:

collections (required)

  • Type: CollectionSlug[]
  • Description: Array of collection slugs where the import functionality should be enabled

enabled (optional)

  • Type: boolean
  • Default: true
  • Description: Enable or disable the plugin functionality
payloadExtendedImportExportPlugin({
  collections: ['posts', 'users', 'pages'], // Enable import for these collections
  enabled: process.env.NODE_ENV !== 'production', // Disable in production
})

How It Works

  1. Upload File: Select and upload your data file (CSV, JSON, etc.)
  2. Preview Data: Review the parsed data before importing
  3. Configure Mapping: Map your file columns to collection fields
  4. Validate: Check for any data validation errors
  5. Import: Execute the import with real-time progress tracking

Supported File Formats

  • CSV - Comma-separated values
  • JSON - JavaScript Object Notation
  • Excel - .xlsx files
  • TSV - Tab-separated values

User Interface

The plugin adds an "Import" button to the list view of enabled collections. Clicking this button opens a drawer with the import interface that guides you through the import process:

  • File Upload: Drag and drop or select files
  • Data Preview: Table view of your data
  • Field Mapping: Visual mapping interface
  • Progress Tracking: Real-time import status
  • Error Handling: Clear error messages and validation

Development

This plugin is built with:

  • TypeScript - Type-safe development
  • React - Modern UI components
  • Payload CMS - Integrated with Payload's admin interface
  • File Processing - Support for multiple file formats

Development Setup

To set up the development environment:

# Clone the repository
git clone https://github.com/saroroce/payload-extended-import-export-plugin

# Install dependencies
pnpm install

# Set up environment variables
cd dev
cp .env.example .env

Environment Configuration:

Create a .env file in the dev folder with the following variables:

# Database connection string
DATABASE_URI="mongodb://localhost:27017/payload-import-export-dev"

# Payload secret for JWT tokens
PAYLOAD_SECRET="your-secret-key-here"

# Optional: Email configuration for testing
EMAIL_FROM="[email protected]"
EMAIL_FROM_NAME="Payload Import Export Plugin"

Important Notes:

  • Update DATABASE_URI to match your database setup (MongoDB, PostgreSQL, etc.)
  • Generate a secure random string for PAYLOAD_SECRET
  • The plugin has been pre-configured in dev/payload.config.ts
# Start development server
pnpm dev

The development server will be available at http://localhost:3000.

Examples

Basic Import Configuration

// payload.config.ts
import { payloadExtendedImportExportPlugin } from 'payload-extended-import-export-plugin'

export default buildConfig({
  collections: [
    {
      slug: 'posts',
      fields: [
        { name: 'title', type: 'text', required: true },
        { name: 'content', type: 'textarea' },
        { name: 'status', type: 'select', options: ['draft', 'published'] },
      ],
    },
  ],
  plugins: [
    payloadExtendedImportExportPlugin({
      collections: ['posts'], // Enable import for posts collection
      enabled: true,
    }),
  ],
})

Advanced Configuration

payloadExtendedImportExportPlugin({
  collections: ['posts', 'users', 'pages'],
  enabled: process.env.NODE_ENV !== 'production', // Disable in production
})

Sample CSV Format

For a posts collection, your CSV might look like:

title,content,status
"My First Post","This is the content of my first post",published
"Draft Post","This is a draft post",draft
"Another Post","More content here",published

Testing

The plugin includes comprehensive tests to ensure reliability:

# Run integration tests
pnpm test:int

# Run end-to-end tests  
pnpm test:e2e

# Run all tests
pnpm test

API Reference

Plugin Configuration

interface PayloadExtendedImportExportPluginConfig {
  collections: CollectionSlug[]  // Required: Array of collection slugs
  enabled?: boolean              // Optional: Enable/disable plugin (default: true)
}

Import Endpoint

The plugin exposes an import endpoint at /api/import that accepts:

  • Method: POST
  • Content-Type: multipart/form-data
  • Body: Form data with file and configuration

Troubleshooting

Common Issues

Import button not visible:

  • Ensure the collection slug is included in the collections array
  • Check that the plugin is properly configured in payload.config.ts

File upload errors:

  • Verify file format is supported (CSV, JSON, Excel, TSV)
  • Check file size limits in your Payload configuration
  • Ensure proper field mapping between file columns and collection fields

Import validation errors:

  • Review required fields in your collection schema
  • Check data types match between import data and field definitions
  • Verify any custom validation rules are met

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Guidelines

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

If you encounter any issues or have questions, please:

  1. Check the GitHub Issues
  2. Create a new issue if needed
  3. Contact the maintainer: saroroce

Similar plugins