Building a JSON to JSONL Converter cover image

Building a JSON to JSONL Converter

January 28, 2025

projects

While building data processing pipelines at work, I kept running into the same little task: convert a JSON file to JSONL. Writing a script was easy enough. I was tired of writing the same one in different projects.

So I added a JSON to JSONL converter to JSONL Tools.

Same data, different shape

An API gives you an array of objects. A pipeline wants one record per line. Here's the difference, using a small example:

[
  {"id": 1, "name": "John Doe"},
  {"id": 2, "name": "Jane Smith"}
]

Becomes:

{"id":1,"name":"John Doe"}
{"id":2,"name":"Jane Smith"}

The conversion itself isn't complicated. Decode the input, encode each record, join the records with newlines. Handling an array and handling a single object are slightly different cases. Unicode and escaped slashes also affect how readable the output is, even when the underlying value is the same.

Putting a UI around it

I used Laravel 11, Livewire, Tailwind, and Alpine. Paste the input, convert it, copy the output. That's the whole job.

The useful part is having that small workflow available without pulling together another script. If I'm wiring up a recurring pipeline, a script belongs in the pipeline. If I just need to change the shape of some data, a browser tool is handy.

JSONL being a line-oriented format doesn't make this particular conversion a streaming operation. Decoding a whole JSON array still means holding that input in memory. That's worth keeping in mind when choosing how to convert a large file.

The converter is free and doesn't require signup. And if you need to check the result, there's a JSONL validator alongside it.