npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kitapp-developers/mongo-import-export

v1.1.8

Published

A modern CLI tool to import/export MongoDB collections to and from JSON or CSV — great for backups, migrations, and local development.

Readme

mongo-import-export

npm downloads Node.js License Build Platform

🚀 mongo-import-export

A modern and powerful CLI tool to import and export MongoDB collections to and from JSON and CSV files. Perfect for backups, migrations, and local development.


✨ Features & Key Advantages

This tool was built to make MongoDB data management as simple and effective as possible:

1. 🎛️ Interactive & User-Friendly

  • A step-by-step interactive prompt guides you through the entire import or export process with clear questions — no need to remember complex commands.

2. 📄 Multiple Format Support

  • JSON — preserves full MongoDB fidelity (e.g., ObjectId, Date)
  • CSV — ideal for spreadsheets like Excel or Google Sheets

3. 🛡️ Data Integrity Guarantee

  • Each export includes a manifest.sha256 with checksums
  • During import, checksums are verified
  • Ensures files haven’t been corrupted or tampered with

4. ⚡ High Performance with Streaming

  • Stream-based processing for JSON files
  • Handles datasets of many gigabytes
  • Keeps memory usage minimal — perfect for large-scale backups/migrations

5. 🧠 Intelligent Database Selection

  • If no database is specified in your connection string:
    • Connects to MongoDB server
    • Lists all available databases
    • Lets you choose interactively

6. 🔄 Advanced Conflict Resolution (During Import)

  • upsert: Replace if exists, insert if not
  • skip: Ignore documents that already exist
  • insert (default): Fail on duplicate _id

7. 📊 Clear Progress Indicators

  • Real-time progress bars per collection
  • Clean and informative CLI output
  • Helpful for long-running operations

8. ⚙️ Configurable via .env File

Set default values and skip repetitive input:

DATA_FOLDER=./data
BATCH_SIZE=1000
LOG_LEVEL=debug
LOG_FILE=mongo_script_log.txt

📦 Installation

Global (recommended for CLI usage):

npm install -g @kitapp-developers/mongo-import-export@latest

Local (as project dependency):

npm install @kitapp-developers/mongo-import-export@latest

🛠️ Usage

Run the CLI:

mongo-import-export

Or use without global install:

npx mongo-import-export

The CLI will guide you through:

  1. Select Action: Import or Export
  2. MongoDB URI:
mongodb://user:password@host:port/
  1. Select Format: json or csv
  2. Database Selection:
    • If URI includes a DB, it's used
    • Otherwise, select from list

For Import:

  • Enter target DB name
  • Choose whether to clear collections
  • Choose conflict resolution strategy: Upsert / Skip / Insert

🧑‍💻 Example Workflow

? Select action: Import data into a database
? Enter MongoDB connection URI: mongodb://localhost:27017
? Select data format: json
? Enter database name to import to: myNewDatabase
? Clear collections before importing? Yes

🎬 Demo

CLI demo

👀 Configuration

Optional .env file for defaults:

DATA_FOLDER=./data
BATCH_SIZE=1000
LOG_LEVEL=info
LOG_FILE=mongo_script_log.txt

Place .env in the same directory where you run the CLI.


⚙️ Requirements

  1. Node.js v20 or higher
  2. MongoDB server accessible via the provided connection URL
  3. Your smile 😊

📖 License

MIT License