CSV to JSON & JSON to CSV Converter - Batch, JSON Lines avatar

CSV to JSON & JSON to CSV Converter - Batch, JSON Lines

Pricing

from $2.40 / 1,000 converted files

Go to Apify Store
CSV to JSON & JSON to CSV Converter - Batch, JSON Lines

CSV to JSON & JSON to CSV Converter - Batch, JSON Lines

CSV to JSON and JSON to CSV converter: batch up to 20 pasted CSV, JSON or JSON Lines files per run with Miller; keep, rename and sort columns, download each result. $0.003 per converted file; empty, invalid or too large files are free.

Pricing

from $2.40 / 1,000 converted files

Rating

0.0

(0)

Developer

Yukai Lin

Yukai Lin

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

20 days ago

Last modified

Features

Limited permissions

Share

What does Tabular Transformer do?

Give it up to 20 CSV, JSON or JSON Lines files in one run; it converts each one with Miller and saves the result as a file you can download: CSV to JSON, JSON to CSV, JSON Lines to CSV and every other pair of the three. Along the way it can keep only some columns, rename columns and sort the rows.

  • Batch, unattended: every file gets its own result and its own row, so one bad file never stops the others.
  • Fixed, safe operations: only select, rename and sort. No scripts, Miller expressions, command-line text or URLs are accepted, so a scheduled run always does exactly what its input says.
  • Faithful values: numbers are written as in your file (9.8870 stays 9.8870); zip codes like 02134 and text like 0xff stay text. Records with different fields (JSON Lines) become one CSV with empty cells where a field is missing.
  • Clear free rows: an empty file, a broken CSV, a column name that does not exist or a file over the size limits gets a free row with errorType and the reason.

Use cases

  • Turn CSV exports (CRM, shop, analytics) into JSON for an API, a database import or an AI agent, on a schedule.
  • Turn JSON or JSON Lines from an API or another Actor into CSV for Excel or Google Sheets.
  • Keep only the columns a partner needs, with their names, in the order they expect.
  • Sort a list by date, amount or name before sending it on.

How much does it cost?

$0.003 per converted file (event file-transformed; Silver plan $0.0027, Gold and above $0.0024). No start fee.

  • A file is charged once, after its result is saved in the key-value store and its row is saved in the dataset.
  • A file that converts correctly but has 0 rows (for example a CSV with only a header line) is a completed conversion and is charged.
  • Free (not charged): empty files, files that are not valid CSV / JSON / JSON Lines, column names that do not exist, files over the size limits, files after the 20th, conversions that time out, results that could not be saved, and files left when your maximum charge per run is reached (errorType: charge_limit).
  • If the run restarts (an Apify server migration), files that already have a row are not converted or charged again.
  • The converted file is not necessarily smaller than the input: CSV to JSON usually makes it bigger.

How to use it

  1. Put your files in Files: [{"name": "sales.csv", "dataText": "<the file's text>"}], up to 20 per run.
  2. Choose the Input format (all files of a run have the same format) and the Output format.
  3. Optionally list Keep only these columns, Rename columns and Sort rows by.
  4. Run. Open the Files (overview) view: each converted file has a download link (outputUrl) to its record in the run's key-value store (outputKey).

Limits

LimitValue
Files per run1 to 20 (more files get a free row each)
One file256 KB of UTF-8 text
All files of a run1 MB together (files past it get a free too_large row)
One converted file4 MB (a bigger result is a free output_too_large row)
Time per file20 seconds per Miller step (longer is a free timeout row)
Keep only these columnsup to 50 names
Rename columnsup to 50 pairs
Sort rows byup to 3 columns, asc or desc

Column names are case sensitive and must exist in the file (sort and rename use the names as they are in the file). Names containing a comma or a line break cannot be used in these options. A rename may not give a column the name of another column, and a renamed column must be among the kept columns when you keep only some. A column whose values are all numbers sorts as numbers; other columns sort as text.

Input example (Miller's official example.csv, first two records)

{
"files": [
{
"name": "example.csv",
"dataText": "color,shape,flag,k,index,quantity,rate\nyellow,triangle,true,1,11,43.6498,9.8870\nred,square,true,2,15,79.2778,0.0130\n"
}
],
"inputFormat": "csv",
"outputFormat": "csv",
"selectColumns": ["color", "shape"]
}

The key-value store record OUTPUT-01-example.csv then holds:

color,shape
yellow,triangle
red,square

Output example (one converted file and the free row of an empty file)

[
{
"inputIndex": 0,
"name": "example.csv",
"outputKey": "OUTPUT-01-example.csv",
"outputUrl": "https://api.apify.com/v2/key-value-stores/<store id>/records/OUTPUT-01-example.csv",
"inputBytes": 116,
"outputBytes": 39,
"recordCount": 2,
"success": true,
"charged": true,
"errorType": null
},
{
"inputIndex": 1,
"name": "empty.csv",
"outputKey": null,
"inputBytes": 0,
"outputBytes": null,
"recordCount": null,
"success": false,
"charged": false,
"errorType": "invalid_input",
"error": "the file is empty (not charged)"
}
]
FieldMeaning
inputIndex, nameposition (from 0) and name of the input file
outputKey, outputUrlkey-value store record of the converted file (OUTPUT-<nn>-<name>.<format>) and its download link
inputBytes, outputBytessize of the input text and of the converted file, in UTF-8 bytes
recordCountdata rows (records) in the converted file; 0 is possible
success, chargedtrue for a converted file. charged: true means the charge is sent: it is written when the row is stored, just before the one charge for that file (a stored row cannot be changed afterwards). In the rare case that the charge does not go through, SUMMARY lists the file's inputIndex: in notCharged when Apify answered without charging it (the file is free), in chargeUnknown when the charge request itself failed, for example timed out, so Apify may or may not have recorded it. The charge is never sent again, so a file is charged at most once; SUMMARY billing and the run's charged events in Apify Console show what was actually charged
errorType, errorwhy a file was not converted (free rows only): invalid_input, too_large, output_too_large, timeout, save_failed, charge_limit, service_unavailable, failed

The run's SUMMARY record counts converted files (succeeded), free rows (freeFailures, by errorTypes) and files whose charge Apify confirmed (chargedFiles, events.file-transformed; converted files whose charge did not go through are left out and listed in notCharged or chargeUnknown, see charged above), lists the output records (outputKeys), the Miller version and the time per file, and adds a billing block with what Apify actually charged.

Use it from code

curl -X POST "https://api.apify.com/v2/acts/tidytools~tabular-transformer/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"files": [{"name": "people.jsonl", "dataText": "{\"id\": 1, \"name\": \"Ada\"}\n{\"id\": 2, \"name\": \"Bob\", \"team\": \"red\"}\n"}], "inputFormat": "jsonl", "outputFormat": "csv"}'

Then download each row's outputUrl.

Limitations

  • Text input only (dataText); no file links or uploads in this version. Excel files must be saved as CSV first.
  • CSV means comma-separated with a header line. Rows with a different number of fields than the header, or an unclosed quote, make the file invalid (free row).
  • All files of a run share one input format and one set of options.
  • JSON output keeps nested objects; CSV output flattens them into columns such as address.city.

FAQ

Can I run my own Miller command or expression? No. Only the three operations above are available, on purpose: a scheduled run cannot be turned into something else by its input.

Why did a file get invalid_input? It is empty, not valid in the chosen input format, or an option names a column it does not have. The error says which, and for a missing column it lists the file's columns.

Does the Actor collect usage data? It sends one anonymous usage counter per run (input type, item count range, outcome) to improve the tool; no file names, content or account data.

Third-party software

This Actor runs Miller 6.22.0 (mlr), unmodified, under its BSD 2-Clause license; the license file is included in the Actor's image at /usr/share/licenses/miller/.

Copyright (c) 2015- John Kerl. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Support

Open an issue in the Issues tab with a small sample of the file and the options you used. Issues are checked regularly.