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

csvdrop

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csvdrop

./jsontocsv/README.md

0.0.6
latest
npm
Version published
Weekly downloads
31
-38%
Maintainers
1
Weekly downloads
 
Created
Source

jsontocsv

A simple TypeScript/JavaScript utility to convert an array of JSON objects into a downloadable CSV file in the browser.

Features

  • Accepts only arrays of objects (JSON format)
  • Escapes quotes and handles special characters
  • Triggers a CSV file download in the browser

Where to Use

  • Web applications: Use in any browser-based project (React, Vue, Angular, plain JS/TS, etc.) where you need to let users export data as CSV.
  • Dashboards: Allow users to download reports or tables as CSV files.
  • Admin panels: Export filtered or tabular data for offline analysis.

Note: This package is intended for use in browser environments. It will not work in Node.js or server-side code, as it relies on browser APIs (document, Blob, URL).

Installation

npm install csvdrop

Usage

import { jsontocsv } from "csvdrop";

const data = [
  { name: "Alice", age: 30 },
  { name: "Bob", age: 25 },
];

jsontocsv(data, "mydata.csv");

API

jsontocsv(data, filename?)

  • data: Array of objects (required)
  • filename: Name for the downloaded CSV file (default: data.csv)

Example

const data = [
  { name: "Alice", age: 30 },
  { name: "Bob", age: 25 },
];
jsontocsv(data, "users.csv");

Notes

  • This function must be run in a browser environment (uses document, Blob, and URL).
  • Throws an error if the input is not a non-empty array of objects.

License

MIT

Keywords

csv

FAQs

Package last updated on 22 May 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