Skip to content

Formatting a JSONL (JSON Lines) file #191

Open

Description

@DrGriff

I'm starting to work a lot with JSONL files (JSON Lines).

I know that the idea behind a JSONL file is that each line in the file is a separate JSON "object", but that makes it very hard to read. I know that I can Format or Compress each line individually, but it would be great if I could Format the whole document to read it and then Compress the whole document again to use it.

Activity

  1. self-assigned this
    on Aug 15, 2024
  2. molsonkiko commented on Sep 1, 2024

    @molsonkiko

    FWIW JsonTools has had support for JSON Lines documents for some time. The tree view works with JSON Lines; no need to reformat them first.

    @SinghRajenM
    If you're curious how I implemented the JSON Lines parser, the source code is here.

  3. SinghRajenM commented on Sep 7, 2024

    @SinghRajenM
    Collaborator

    @molsonkiko thanks for the info.
    Currently, this plugin uses rapidjson under the hood to parse json. I am exploring some other options as rapidjson's sax parser does provide line/position information. I am trying to figure some existing parser instead of write owner custom parser.

  4. WolfgangHG commented on Aug 13, 2026

    @WolfgangHG

    Just an idea: would it make sense to convert the JSONL to "real" json, which can be easily formatted?
    This would mean adding square brackets around the file content, and adding a comma at the end of each line:

    Original json:

    {"prop1":"value1.1","prop2":"value2.1"}
    {"prop1":"value1.2","prop2":"value2.2"}

    Converted json:

    [
      {
        "prop1": "value1.1", 
        "prop2": "value2.1"
      },
      { 
        "prop1": "value1.2", 
        "prop2": "value2.2"
      }
    ]

    A menu item "convert JSONL to JSON" could do this.

  5. sapph42 commented on Sep 30, 2026

    @sapph42

    I have added a PR for this. #256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions