https://github.com/maxlath/ndjson-2-json
minimal CLI converter from newline-delimited JSON to a JSON array
https://github.com/maxlath/ndjson-2-json
cli converter json jsonl ndjson
Last synced: 7 months ago
JSON representation
minimal CLI converter from newline-delimited JSON to a JSON array
- Host: GitHub
- URL: https://github.com/maxlath/ndjson-2-json
- Owner: maxlath
- Created: 2020-01-17T14:24:44.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T16:19:42.000Z (about 1 year ago)
- Last Synced: 2025-01-29T16:39:22.706Z (8 months ago)
- Topics: cli, converter, json, jsonl, ndjson
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ndjson-2-json
Minimal CLI converter from [newline-delimited JSON](https://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON) to a [JSON](https://en.wikipedia.org/wiki/JSON) array
Features:
* converts NDJSON to JSON
* uses streams to be able to handle very large files with minimal memory use
* zero validation: you have the responsability to send some proper newline-delimited JSON on `ndjson-2-json` [stdin](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin))## Install
```sh
npm i -g ndjson-2-json
```## How to
```sh
# Convert all a file
cat some.ndjson | ndjson-2-json > some.json
# which can also be written
ndjson-2-json < some.ndjson > some.json# Convert just the 20 first lines
head -n 20 some.ndjson | ndjson-2-json > 20_first_entries.json
```## See also
* [ndjson-apply](https://github.com/maxlath/ndjson-apply)
* [ndjson-cli](https://github.com/mbostock/ndjson-cli)