🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@simuratli/react-json-csv-converter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simuratli/react-json-csv-converter

React json to csv converter

1.1.1
latest
Source
npm
Version published
Weekly downloads
97
-80.36%
Maintainers
1
Weekly downloads
 
Created
Source

📦 @simuratli/react-json-csv-converter

A lightweight and customizable React component that enables users to download JSON data as a CSV file with a single button click.

🚀 Features

  • 🧠 Auto-detects headers from your JSON data.
  • 🎯 Supports custom headers with label/key mapping.
  • 💡 Handles special characters in CSV (e.g., commas, quotes, newlines).
  • ⚛️ Fully typed with TypeScript.
  • 🎨 Accepts any button props (className, disabled, etc.) for customization.

📦 Installation

npm install @simuratli/react-json-csv-converter

or

yarn add @simuratli/react-json-csv-converter

✨ Usage

1. Auto-detect headers from JSON:

import { JsonToCsvDownload } from '@simuratli/react-json-csv-converter';

const data = [
  { id: 1, name: 'Alice', age: 30 },
  { id: 2, name: 'Bob', age: 25 }
];

<JsonToCsvDownload data={data} filename="users.csv">
  Export Users
</JsonToCsvDownload>;

2. With custom headers (label + key):

import { JsonToCsvDownload } from '@simuratli/react-json-csv-converter';

const data = [
  { id: 1, name: 'Alice', age: 30 },
  { id: 2, name: 'Bob', age: 25 }
];

const headers = [
  { label: 'User ID', key: 'id' },
  { label: 'Full Name', key: 'name' },
  { label: 'User Age', key: 'age' }
];

<JsonToCsvDownload
  data={data}
  headers={headers}
  filename="custom_users.csv"
  className="my-custom-button"
>
  Download CSV
</JsonToCsvDownload>;

📘 Props

PropTypeDescription
dataobject[]Required. The JSON array to convert and download as CSV.
headers{ label: string, key: string }[] | nullOptional. Custom headers for CSV: display label and extract from key.
filenamestringOptional. Name of the downloaded CSV file. Default is data.csv.
classNamestringOptional. Custom CSS classes for the button.
childrenReactNodeOptional. Button label/content. Default is "Download CSV".
onDownload() => voidOptional. Callback after successful CSV download.
...propsButtonHTMLAttributes<HTMLButtonElement>Optional. All standard <button> props supported.

🧪 Development

npm run dev

📄 License

MIT © Your Name or GitHub Handle

Keywords

react

FAQs

Package last updated on 07 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts