Documentation

Export Data - JSON, CSV, SQL

Tasks Management

Create and manage individual export/import jobs with advanced configuration options. Configure source, target, field mapping, and transformation scripts for data migration between MongoDB, SQL databases, and file formats (JSON, CSV, BSON, SQL).

Quick Start

Create and execute your first export job in just a few steps:

  1. Right-click on a collection or database in the sidebar and select "Export Data"
  2. Choose your target format (JSON, CSV, SQL, BSON, or MongoDB Collection)
  3. Configure field mapping and transformation options if needed
  4. Click "Execute" to run immediately or "Save" to schedule for later
Video EXPD01 Creating a New Export Job - Right-click collection and select Export Data, choose source and target types, configure connections and paths, save or execute the job
Screenshot EXPD02 Export job configuration interface showing source, target, and transformation sections

Job Configuration

Each export/import job consists of three main configuration areas: Source, Target, and Data Transformation.

Source Configuration

Define where your data comes from. VisualLeaf supports multiple source types for maximum flexibility.

Source Type Description Configuration Options
MongoDB Collection Export all documents from a specific collection Connection, database, collection
MongoDB Query Export filtered data using MongoDB query syntax Query filter, projection, sort, limit, skip
MongoDB Aggregation Export data processed through aggregation pipeline Pipeline stages, $match, $group, $lookup, etc.
MongoDB Database Export entire database with all collections Connection, database, folder path for output
MongoDB Script Execute custom MongoDB shell script as source Connection, database, JavaScript code
MongoDump Import from MongoDB dump files (BSON format) Folder path containing BSON files
SQL Table Export data from a SQL database table SQL connection, database, table name
SQL Query Export data using custom SQL SELECT statement SQL connection, custom SELECT query
JSON Import from JSON file (array or line-delimited) File path, format detection (auto)
CSV Import from CSV file with configurable delimiters File path, delimiter, has header row
Notification Send notification only (no data export) Notification settings
Screenshot EXPD03 Source configuration panel showing connection, database, and collection selection with query editor

Target Configuration

Choose where to export your data. Each target type has specific configuration options.

Target Type Description Configuration Options
JSON Export to JSON file (array or line-delimited) File path, format, pretty print, UTF-8 encoding
CSV Export to CSV file with custom delimiters File path, delimiter, header row, encoding
MongoDB Export (BSON) Export to MongoDB BSON format (mongoexport) File/folder path, compression options
MongoDB Collection Export directly to another MongoDB collection Connection, database, collection, write mode
SQL Script Generate SQL INSERT/UPDATE statements File path, SQL dialect, batch size, transaction mode
SQL Database Export directly to SQL database table SQL connection, table, write mode, create table
Screenshot EXPD04 Target configuration panel showing export format selection and file path settings

Data Transformation & Field Mapping

Transform your data during export/import with powerful field mapping and JavaScript transformation scripts. Perfect for data cleansing, format conversion, and schema adaptation.

Field Mapping

Map source fields to target fields with automatic type detection and manual override options. The field mapper shows a live preview of your data transformation.

  • Auto-detect Fields - Automatically discovers fields from source data (first 100 documents)
  • Drag & Drop Mapping - Visually map source fields to target fields
  • Field Renaming - Change field names during migration
  • Type Conversion - Convert between data types (string to number, date parsing, etc.)
  • Nested Field Support - Handle nested objects and arrays with dot notation
  • Exclude Fields - Unmap fields you don't want to export
  • Add Computed Fields - Create new fields using transformation scripts
Video EXPD05 Configuring Field Mapping - Auto-detect fields, rename target fields, apply type conversions, exclude unwanted fields, add computed fields, and preview transformations
Screenshot EXPD06 Field mapping interface showing source and target fields with transformation preview

Transformation Scripts

Write custom JavaScript functions to transform field values during export/import. Each field can have its own transformation script.

Script Context: Your transformation scripts have access to these variables:

  • value - The current field value
  • doc - The entire source document
  • target - The target document being built
  • index - Document index in the batch

Example Transformations

// Convert string to uppercase
return value?.toString().toUpperCase();

// Parse date string to Date object
return new Date(value);

// Combine multiple fields
return `${doc.firstName} ${doc.lastName}`;

// Conditional transformation
return value > 100 ? 'high' : 'low';

// Array transformation
return value?.map(item => item.id);

Preview & Testing

Before running your export/import job, preview the transformation results on sample data. The preview shows both the original and transformed documents side-by-side.

  • Build Preview - Test your transformations on up to 100 sample documents
  • Script Validation - Automatic syntax checking for transformation scripts
  • Error Detection - Highlights documents where transformation failed
  • Performance Testing - Configurable timeout (default 15s) to test complex transformations
Screenshot EXPD07 Transformation preview showing sample documents before and after field mapping and scripts

Execution Monitor

Track the progress of running export/import jobs in real-time with detailed status updates and error reporting via Server-Sent Events (SSE).

Progress Tracking

  • Real-time Progress Bar - Visual indicator showing completion percentage
  • Status Updates - Current operation (reading, transforming, writing)
  • Document Counter - Shows processed/total documents
  • Error Messages - Immediate notification of failures with details
  • SSE Connection - Live updates from server via Server-Sent Events
  • Auto-refresh Database - Database tree refreshes automatically on completion

Job Status States

Status Description
Pending Job is queued and waiting to start
Running Job is currently executing
Completed Job finished successfully
Failed Job encountered an error and stopped
Cancelled Job was manually stopped by user
Video EXPD08 Running and Monitoring Export Tasks - Execute job, watch real-time progress, monitor status updates, view document counter, check for errors, wait for completion, and verify results
Screenshot EXPD09 Job execution progress bar showing status, operation, and completion percentage

Actions

Execute

Run the export/import job immediately. The job automatically saves before execution, then starts processing. Monitor progress in real-time with SSE updates. Success toast notification shown on completion.

Save

Save the job configuration. After saving, you'll be prompted: "Do you want to go to the Job Manager?" Choose "Yes" to navigate to Task Manager, or "No" to close. Use Ctrl+S (Cmd+S on Mac) as a shortcut.

Build Preview

Test your transformation scripts and field mappings on sample data (up to 100 documents) before running the full job. Shows side-by-side comparison of source and transformed documents with validation errors highlighted.

Auto-Generate Name

Automatically creates a descriptive job name based on source and target configuration (e.g., "users_collection_to_csv", "mongodb_to_mysql_migration"). Click the magic wand icon in the job title.

Close/Cancel

Close the job configuration without saving changes. Press Escape key as a shortcut (unless editing the job name). For modal mode, closes the modal. For embedded mode, returns to previous view.

Keyboard Shortcuts

Shortcut Action
Ctrl+S (or Cmd+S on Mac) Save job configuration
Esc Close job configuration (cancel)

Pro Tips

  1. Always test your transformation scripts with "Build Preview" before running on large datasets. This catches syntax errors and logic issues early.
  2. For MongoDB Query sources, use projection to reduce data transfer by exporting only the fields you need instead of entire documents (e.g., {name: 1, email: 1, _id: 0}).
  3. When exporting to SQL databases, field names are automatically converted to valid SQL identifiers. Special characters and spaces in MongoDB field names become underscores.
  4. For database exports (MongoDB Database source), specify a folder path where each collection will be saved as a separate file with the collection name.
  5. The job continues running in the background via SSE even if you close the dialog. After completion, the database tree automatically refreshes to show new collections.
  6. When importing JSON files, VisualLeaf auto-detects the format (array [{}, {}] or line-delimited {} {}). The file must be validated before preview works.
  • Task Manager - Organize jobs into folders, set up dependencies, schedule execution, and monitor running tasks
  • Collection Activity - Export data directly from the collection view with current query filters applied
  • Aggregation Pipeline - Create complex data transformations before export using MongoDB aggregation stages
  • SQL Query Activity - Write custom SQL queries as source for migration to MongoDB with preview
  • Execution Monitor - View all running, scheduled, and completed jobs in the Task Manager's Monitor tab

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial