Actor picture

JSON to CSV Converter


If you are looking for a solution that will convert your big JSON (array of JSON objects) to a CSV/Excel in JS, this is a droid you are looking for. Paste to the input an URL for a JSON and name of the dataset where we will store the records. You can provide more than 1 URL for the JSON, see input example. Actor is using our dataset to handle the converting the items, we just simply push items to the dataset and then download the whole dataset. Apify do the magic for us.


const Apify = require('apify');
const rp = require('request-promise')
const Promise = require('bluebird')
const ApifyClient = require('apify-client');

Apify.main(async () => {

    const input = await Apify.getValue('INPUT');
    const environmentVariables = await Apify.getEnv()

    const apifyClient = new ApifyClient({
        userId: environmentVariables.userId,
        token: environmentVariables.token
    const datasets = apifyClient.datasets;

    await, async (solve) => {

        if (! || !solve.url) throw new Error('Invalid input! Please provide combination of name and url');

        const inputData = await rp({uri: solve.url});

        const dataset = await datasets.getOrCreateDataset({
            datasetName: + environmentVariables.actRunId,

        const parsedData = JSON.parse(inputData);
        console.log("Loaded", parsedData.length, " for ",;

        while (parsedData.length) {
            console.log("Remaining records for",, " is: ", parsedData.length)
            await datasets.putItems({datasetId:,data: parsedData.splice(0, 1000)});
        console.log(," finished.")
        console.log("Download a CSV :" + + "/items?format=csv&attachment=1");
        console.log("Download a XLSX :" + + "/items?format=xlsx&attachment=1");

    }, {concurrency: 10})

    console.log("Job finished, see you next time.");

Actor expects the file on the input in this structure:

    "name":"Here is a name of the object 1.",
    "value1": 1,
    "end":"Thanks for watching!"
    "name":"Here is a name of the object 2.",
    "value1": 1,
    "end":"Thanks for watching!"
  • Updated
  • Last run
  • Used54 times
  • Used by12 users