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 🙏

© 2024 – Pkg Stats / Ryan Hefner

convert-json-into-csv

v1.1.18

Published

This is a npm package to convert JSON object format to CSV format with dynamic keys from the JSON object. You do not need to define the CSV format to convert.

Downloads

20

Readme

Convert JSON into CSV

     ___     _________      __________      _____     ___
    /\  \   /\   _____\    /\   ____  \    /\    \   /\  \
    \ \  \  \ \  \____/    \ \  \__/\  \   \ \  \  \ \ \  \
     \ \  \  \ \  \_______  \ \  \ \ \  \   \ \  \\  \\ \  \
  __  \ \  \  \ \_______  \  \ \  \ \ \  \   \ \  \ \  \ \  \
 /\  \ \ \  \  \/______/\  \  \ \  \ \ \  \   \ \  \\ \  \\  \
 \ \  \_\_\  \     ____\_\  \  \ \  \_\_\  \   \ \  \ \ \  \  \
  \ \_________\   /\_________\  \ \_________\   \ \__\  \ \____\
   \/_________/   \/_________/   \/_________/    \/__/   \/____/

 ____________     __________
/\____   ____\   /\   ____  \
\/___/\  \___/   \ \  \__/\  \
     \ \  \       \ \  \ \ \  \
      \ \  \       \ \  \ \ \  \
       \ \  \       \ \  \ \ \  \
        \ \  \       \ \  \_\_\  \
         \ \__\       \ \_________\
          \/__/        \/_________/

 _________     _________      ___    ___
/\   _____\   /\   _____\    /\  \  /\  \
\ \  \____/   \ \  \____/    \ \  \ \ \  \
 \ \  \        \ \  \_______  \ \  \ \ \  \
  \ \  \        \ \_______  \  \ \  \ \ \  \
   \ \  \        \/______/\  \  \ \  \ \/  /
    \ \  \______     ____\_\  \  \ \  \/  /
     \ \________\   /\_________\  \ \____/  
      \/________/   \/_________/   \/___/

                             

It is a npm package with a function which receives a JSON object as a parameter and returns a CSV data to show in tabular form.

New Features

:white_check_mark:    Custom key separator :boom: :white_check_mark:    Custom text delimiter and text separator :boom:

Setup process

npm install convert-json-into-csv --save

Function Parameters

  1. JSON object [Object:Required] :- a JSON object which you want to convert to csv.
  2. Key Separator [String:Optional] :- a symbol to separate the JSON key names of parent and child object. Default value is _.
  3. Delimeter [String:Optional] :- a symbol to wrap the CSV value. Default value is ".
  4. Value Separator [String:Optional] :- a symbol to separate the diffent values of CSV. Default value is ,.

Use Method

Example 1 :

import JsonToCsv from 'convert-json-into-csv'; //ES6
//OR
const JsonToCsv = require('convert-json-into-csv'); //ES5

let csv = ``;
let json = {
    name: 'Saimon Thada Magar',
    company: 'ChicMic, Mohali, India',
    profession: 'Software Engineer',
    address: {
        city: 'Khoptar -4, Rampur',
        country: 'Nepal'
    }
}

csv = JsonToCsv(json);
console.log(csv);

Output (return value):

"name","company","profession","address_city","address_country"
"Saimon Thada Magar","ChicMic, Mohali, India","Software Engineer","Khoptar -4, Rampur","Nepal"

CSV Tabular View:

name | company | profession | address_city | address_country ---- | ------- | ---------- | ------------ | --------------- Saimon Thada Magar | ChicMic, Mohali, India | Software Engineer | Khoptar -4, Rampur | Nepal

Example 2 :

import JsonToCsv from 'convert-json-into-csv'; //ES6
//OR
const JsonToCsv = require('convert-json-into-csv'); //ES5

let csv = ``;
let json = {
    name: 'Saimon Thada Magar',
    company: 'ChicMic, Mohali, India',
    profession: 'Software Engineer',
    address: {
        city: 'Khoptar -4, Rampur',
        country: 'Nepal'
    },
    hobbies: ['Programming','Music','Sports']
}

csv = JsonToCsv(json,'-',"'",'.');
console.log(csv);

Output (return value):

'name'.'company'.'profession'.'address-city'.'address-country'.'hobbies'
'Saimon Thada Magar'.'ChicMic, Mohali, India'.'Software Engineer'.'Khoptar -4, Rampur'.'Nepal'.'Programming'
''.''.''.''.''.'Music'
''.''.''.''.''.'Sports'

CSV Tabular View:

name | company | profession | address_city | address_country | hobbies ---- | ------- | ---------- | ------------ | --------------- |------ Saimon Thada Magar | ChicMic, Mohali, India | Software Engineer | Khoptar -4, Rampur | Nepal | Programming | | | | | | Music | | | | | | Sports

Upcoming new Features

:soon: Custom column names instead of joined JSON keys.