# json2jsonl
![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)

A lightweight command-line tool to convert multiple JSON files into a single [JSONL (JSON Lines)](https://jsonlines.org/) output file.

It automatically handles:
- **Arrays**: Flattens top-level JSON arrays into individual lines.
- **Objects**: Writes single JSON objects as individual lines.
- **Mixed Content**: Can process files containing both arrays and objects, or multiple concatenated JSON values.

## Provided by
**[wizhut.tech company](https://wizhut.tech)**
This tool is free-to-use for any purpose.

## Usage

```bash
json2jsonl [options] <file1.json> <file2.json> ...
```

### Options

- `-o string`: Output file path. If omitted, output is written to standard output (stdout).
- `-h`: Show help message.

### Examples

**Convert multiple files and save to `output.jsonl`:**
```bash
json2jsonl -o output.jsonl data1.json data2.json
```

**Convert a file and pipe output to another command:**
```bash
json2jsonl data.json | grep "foo"
```

## Build Instructions

### Prerequisites
- [Go](https://go.dev/dl/) (1.16+ recommended)
- `make` (optional, for cross-compilation)

### Build Locally
```bash
go build -o json2jsonl
```

### Cross-Platform Build (using Make)
To build binaries for MacOS (Intel/ARM), Windows, and Linux:

```bash
make all
```

This will create a `bin/` directory with the following executables:
- `json2jsonl-darwin-amd64` (MacOS Intel)
- `json2jsonl-darwin-arm64` (MacOS Apple Silicon)
- `json2jsonl-linux-amd64` (Linux 64-bit)
- `json2jsonl-windows-amd64.exe` (Windows 64-bit)

## License
Free to use for any purpose.
