Import-Export plugin for Payload
npm install @afzalimdad9/payload-import-exportA comprehensive plugin for Payload to easily import and export collection data in CSV and JSON formats.
- Export collection data as CSV or JSON
- Download exports directly or save as file uploads
- Selective field and document export
- Support for nested objects and relationships
- Jobs queue integration for large exports
- Customizable CSV output formatting
- Import data from CSV or JSON files
- Data preview and validation before processing
- Support for creating new documents and updating existing ones
- Comprehensive error handling and reporting
- Progress tracking and status updates
- Automatic type conversion and nested object handling
``bash`
pnpm add @afzalimdad9/payload-import-export
`ts
import { buildConfig } from 'payload'
import { importExportPlugin } from '@afzalimdad9/payload-import-export'
export default buildConfig({
plugins: [
importExportPlugin({
collections: ['users', 'posts'], // Optional: specify collections
}),
],
// ... rest of config
})
`
- Full Documentation
- Source Code
| Option | Type | Description |
| -------------------------- | ----------------- | ------------------------------------------------------ |
| collections | string[] | Collections to enable import/export for (default: all) |disableImport
| | boolean | Disable import functionality |disableDownload
| | boolean | Disable direct download of exports |format
| | 'csv' \| 'json' | Force specific format and hide format selector |overrideImportCollection
| | function | Customize the import collection configuration |overrideExportCollection
| | function | Customize the export collection configuration |
1. Navigate to any collection list view
2. Use the "Export" option in the list controls
3. Configure export settings (format, fields, filters)
4. Download directly or save as file upload
1. Navigate to any collection list view
2. Use the "Import" option in the list controls
3. Paste CSV or JSON data into the import form
4. Preview and validate the data
5. Process the import with progress tracking
The plugin handles complex data structures in CSV format:
- Nested objects: user.profile.name → { user: { profile: { name: "value" } } }tags.0
- Arrays: , tags.1 → { tags: ["value1", "value2"] }
- Relationships: Supports ID references and basic validation
- POST /api/exports/download - Direct export downloadPOST /api/imports/preview
- - Preview import dataPOST /api/imports/process` - Process import
-
MIT - see license.md