Back to rankings

tableflowhq/csv-import

TypeScripttableflow.com

The open-source CSV importer, maintained by @tableflowhq

file-sharingfile-uploadimportimporterreacttypescriptuploaduploadercsvexcel
Star Growth
Stars
1.8k
Forks
127
Weekly Growth
Issues
27
1k1.5k
Feb 2023Mar 2024May 2025Jul 2026
Artifactsnpmnpm install csv-import
README
CSV Import

Open-source CSV, TSV, and XLS/XLSX file importer for React and JavaScript

How It Works

  1. Embed the CSV Importer in your app with the React or JavaScript SDK
  2. Define the columns your users can import (via the template parameter)
  3. Your users import their files in your app
  4. Retrieve the imported data from the onComplete event

Importer Modal

Get Started

1. Install SDK

Use NPM or Yarn to install the SDK for React or JavaScript.

NPM

npm install csv-import-react
# or
npm install csv-import-js

Yarn

yarn add csv-import-react
# or
yarn add csv-import-js

2. Add the importer to your application

Using React

import { CSVImporter } from "csv-import-react";
import { useState } from "react";

function MyComponent() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Open CSV Importer</button>

      <CSVImporter
        modalIsOpen={isOpen}
        modalOnCloseTriggered={() => setIsOpen(false)}
        darkMode={true}
        onComplete={(data) => console.log(data)}
        template={{
          columns: [
            {
              name: "First Name",
              key: "first_name",
              required: true,
              description: "The first name of the user",
              suggested_mappings: ["First", "Name"],
            },
            {
              name: "Age",
            },
          ],
        }}
      />
    </>
  );
}

Using JavaScript

<head>
  <script src="https://unpkg.com/csv-import-js@latest/index.js"></script>
</head>
<body>
  <button id="uploadButton">Open CSV Importer</button>
  <div id="app"></div>
  <script>
    const importer = CSVImporter.createCSVImporter({
      domElement: document.getElementById("app"),
      modalOnCloseTriggered: () => importer?.closeModal(),
      onComplete: (data) => console.log(data),
      darkMode: true,
      template: {
        columns: [
          {
            name: "First Name",
            key: "first_name",
            required: true,
            description: "The first name of the user",
            suggested_mappings: ["First", "Name"],
          },
          {
            name: "Age",
          },
        ],
      },
    });

    const uploadButton = document.getElementById("uploadButton");
    uploadButton.addEventListener("click", () => {
      importer?.showModal();
    });
  </script>
</body>

SDK Reference

isModal (boolean, default: true)

When set to true (default value), the importer will behave as a modal with its open state controlled by modalIsOpen. When set to false, the importer will be embedded directly in your page.

modalIsOpen (boolean, default: false)

Only used when isModal is true: Controls the importer modal being open or closed.
React SDK Only: For the JavaScript SDK, use .showModal() and .closeModal() to operate the modal.

modalOnCloseTriggered (function)

Only used when isModal is true: A function called when the user clicks the close button or clicks outside of (when used with modalCloseOnOutsideClick) the importer. useState can be used to control the importer modal opening and closing.

const [isOpen, setIsOpen] = useState(false);
<button onClick={() => setIsOpen(true)}>Open CSV Importer</button>
<CSVImporter
  modalIsOpen={isOpen}
  modalOnCloseTriggered={() => setIsOpen(false)}
  ...
/>

modalCloseOnOutsideClick (boolean, default: false)

Only used when isModal is true: Clicking outside the modal will call the modalOnCloseTriggered function.

template (object)

Configure the columns used for the import.

template={{
  columns: [
    {
      name: "First Name",
      key: "first_name",
      required: true,
      description: "The first name of the user",
      suggested_mappings: ["First", "Name"],
    },
    {
      name: "Age",
    },
    {
      name: "Category",
      // `multiple` allows multiple source columns to be mapped to a single destination column
      multiple: true,
      // `combiner` is the function used to combine the values from multiple source columns; defaults to joining with a space
      combiner: (values: string[]) => values.join(' | '),
    }
  ],
}}

onComplete (function)

Callback function that fires when a user completes an import. It returns data, an object that contains the row data, column definitions, and other information about the import.

onComplete={(data) => console.log(data)}

Example data:

{
  "num_rows": 2,
  "num_columns": 3,
  "columns": [
    {
      "key": "age",
      "name": "Age"
    },
    {
      "key": "email",
      "name": "Email"
    },
    {
      "key": "first_name",
      "name": "First Name"
    }
  ],
  "rows": [
    {
      "index": 0,
      "values": {
        "age": 23,
        "email": "maria@example.com",
        "first_name": "Maria"
      }
    },
    {
      "index": 1,
      "values": {
        "age": 32,
        "email": "robert@example.com",
        "first_name": "Robert"
      }
    }
  ]
}

darkMode (boolean, default: false)

Toggle between dark mode (true) and light mode (false).

primaryColor (string)

Specifies the primary color for the importer in hex format. Use customStyles to customize the UI in more detail.

primaryColor = "#7A5EF8";

customStyles (object)

Apply custom styles to the importer with an object containing CSS properties and values. Note that custom style properties will override primaryColor and any default styles from darkMode. Available options:

customStyles={{
  "font-family": "cursive",
  "font-size": "15px",
  "base-spacing": "2rem",
  "border-radius": "8px",
  "color-primary": "salmon",
  "color-primary-hover": "crimson",
  "color-secondary": "indianRed",
  "color-secondary-hover": "crimson",
  "color-tertiary": "indianRed",
  "color-tertiary-hover": "crimson",
  "color-border": "lightCoral",
  "color-text": "brown",
  "color-text-soft": "rgba(165, 42, 42, .5)",
  "color-text-on-primary": "#fff",
  "color-text-on-secondary": "#ffffff",
  "color-background": "bisque",
  "color-background-modal": "blanchedAlmond",
  "color-input-background": "blanchedAlmond",
  "color-input-background-soft": "white",
  "color-background-menu-hover": "bisque",
  "color-importer-link": "indigo",
  "color-progress-bar": "darkGreen"
}}

Internationalization

Predefined languages

  • Out-of-the-box support for various languages.
  • Common languages are available through the language prop (i.e., language="fr" for French).
  • Available predefined languages:
    • en
    • es
    • fr

Customizable language

  • Language keys can be exported and overridden.
  • Labels and messages can be customized to any text.
  • Translations key examples can be found in src/i18n/es.ts
// Set up custom translations
const customTranslations = {
  jp: {
    Upload: "アップロード",
    "Browse files": "ファイルを参照",
  },
  pt: {
    Upload: "Carregar",
    "Browse files": "Procurar arquivos",
  },
};

return (
  <CSVImporter language="jp" customTranslations={customTranslations} ...props />
)

showDownloadTemplateButton (boolean, default: true)

When set to false, hide the Download Template button on the first screen of the importer.

skipHeaderRowSelection (boolean, default: false)

When set to true, the importer will not display and skip the Header Row Selection step and always choose the first row in the file as the header.

Contributing

Setting Up the Project

To set up the project locally, follow these steps:

  1. Clone the repository
git clone https://github.com/tableflowhq/csv-import.git
cd csv-import
  1. Install dependencies
yarn install
  1. Build the project
yarn build

Running Storybook

To run Storybook locally, follow these steps:

  1. Start Storybook
yarn storybook
  1. Open Storybook in your browser: Storybook should automatically open in your default browser. If it doesn't, navigate to http://localhost:6006.

Modifying the project and testing with the demo app

The project includes a demo app that you can use to test your changes. The demo app has its own README.md file with detailed instructions on how to set it up and run it.

  1. Make your changes in the codebase.
  2. Follow the instructions in the demo app's README.md to set up and run the demo app. This will help you verify that your changes work as expected in a real application.
  3. Commit your changes and push them to your forked repository.
  4. Create a pull request to the main repository.

Get In Touch

Let us know your feedback or feature requests! Submit a GitHub issue here.

Related repositories
localsend/localsend

An open-source cross-platform alternative to AirDrop

DartApache License 2.0flutterfile-sharing
localsend.org
85.7k4.7k
9001/copyparty

Portable file server with accelerated resumable uploads, dedup, WebDAV, SFTP, FTP, TFTP, zeroconf, media indexer, thumbnails++ all in one file

PythonPyPIMIT Licensenas-frontendfile-sharing
45.8k1.9k
ShareX/ShareX

ShareX is a free and open-source application that enables users to capture or record any area of their screen with a single keystroke. It also supports uploading images, text, and various file types to a wide range of destinations.

C#GNU General Public License v3.0screen-capturescreen-recorder
getsharex.com
38.7k3.9k
schollz/croc

Easily and securely send things from one computer to another :crocodile: :package:

GoGo ModulesMIT Licensefile-sharingtcp
schollz.com/software/croc6
36.9k1.5k
nextcloud/server

☁️ Nextcloud server, a safe home for all your data

PHPPackagistGNU Affero General Public License v3.0open-sourcefile-sharing
nextcloud.com
36.2k5.1k
filebrowser/filebrowser

📂 Web File Browser

GoGo ModulesApache License 2.0file-browserfile-manager
filebrowser.org
35.6k4k
cloudreve/cloudreve

🌩 Self-hosted file management and sharing system, supports multiple storage providers

GoGo ModulesGNU General Public License v3.0file-sharingfile
cloudreve.org
28.4k3.9k
cloudreve/Cloudreve

🌩支持多家云存储的云盘系统 (Self-hosted file management and sharing system, supports multiple storage providers)

GoGo ModulesGNU General Public License v3.0file-sharingfile
cloudreve.org
22.5k3.5k
haiwen/seafile

Beyond file syncing and sharing, a new way to organize your files with extensible file properties and flexible views

COthercloud-storagefile-sync
seafile.com
15k1.7k
schlagmichdoch/PairDrop

PairDrop: Transfer Files Cross-Platform. No Setup, No Signup.

JavaScriptnpmGNU General Public License v3.0nodejspwa
pairdrop.net
11k658
ShareDropio/sharedrop

Easy P2P file transfer powered by WebRTC - inspired by Apple AirDrop

JavaScriptnpmMIT Licensewebrtcpeer-to-peer
sharedrop.io
10.7k866
sigoden/dufs

A file server that supports static serving, uploading, searching, accessing control, webdav...

Rustcrates.ioApache License 2.0cloud-diskcommand-line
10.5k568