Skip to content

How to tabulate JSON from stdin? #173

Closed

Description

@iainelder

When I run a command like this:

tabulate --format github - <<"EOF"
[
    {
        "column1": "data",
        "column2": 123,
        "column3": true,
        "column4": null
    },
    {
        "column1": "Longer string",
        "column2": 123,
        "column3": true,
        "column4": null
    }
]
EOF

I expect output like this:

| column1       |   column2 | column3   | column4   |
|---------------|-----------|-----------|-----------|
| data          |       123 | True      |           |
| Longer string |       123 | True      |           |

Unfortunately I get output like this:

|---|------------|---------|----------|
| [ |            |         |          |
|   | {          |         |          |
|   | "column1": | "data", |          |
|   | "column2": | 123,    |          |
|   | "column3": | true,   |          |
|   | "column4": | null    |          |
|   | },         |         |          |
|   | {          |         |          |
|   | "column1": | "Longer | string", |
|   | "column2": | 123,    |          |
|   | "column3": | true,   |          |
|   | "column4": | null    |          |
|   | }          |         |          |
| ] |            |         |          |

In the README for the command-line utility I don't see any input format options or an expected input format.

As a library the README says tabulate supports "list or another iterable of dicts (keys as columns)". This matches my use case as it's what you would get after converting the input to via json.load

Am I missing something?

If not, would you consider supporting this use case?

Currently I use jtbl for this (kellyjonbrazil/jtbl#9) but I'd like tabulate to support it too as it has even more useful formatting options.

If it's not possible to guess the input format I'd accept something like an --input-format json similar to in2csv's --format json option.

Activity

  1. astanin commented on Oct 7, 2022

    @astanin
    Owner

    tabulate as a command line tool is somewhat behind tabulate the library. In particular at the moment it handles only white-space-separated values as input, and only a subset of output formats and options. It can definitely be improved.

  2. added this to the v0.10 milestone on Oct 19, 2022
  3. Tatsh commented on Apr 28, 2023

    @Tatsh

    May want to use the jq utility with its @csv filter. I was looking to do the same but with lists of lists.

    Stack Overflow question

  4. modified the milestones: v0.10.0, v0.11.0 on Mar 9, 2026
  5. astanin commented on Mar 9, 2026

    @astanin
    Owner

    Given the wide adoption of JSONL, it would probably be useful to add support of it in the tabulate CLI utility.

  6. added
    enhancementNew feature or request
    and removed
    help wantedExtra attention is needed
    on Mar 9, 2026
  7. added a commit that references this issue on Mar 10, 2026
    c327d6c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions