You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add --json output flag for batch query results #263
litecli already supports --csv and --table for batch output (used with -e and stdin queries), but it has no equivalent --json flag. The underlying cli_helpers library already ships a json_output_adapter.py, so the formatter is available — only the CLI flag is missing.
Solution
Add a --json flag parallel to the existing --csv and -t/--table options on the root cli command. In the -e and stdin branches of litecli/main.py, set litecli.formatter.format_name = "json" next to the existing format_name = "csv" / "tsv" assignments. The change should be ~5 lines.
A table_format = "json" entry could also be accepted in ~/.config/litecli/config, mirroring the existing table_format = "csv" knob.
Use case
Scripting and CI pipelines:
litecli mydb.sqlite -e "select id, name from users" --json | jq '.[] | select(.name | startswith("a"))'
…instead of having to pipe --csv through jq -r '@csv' round-tripping.
It turned out cli_helpers registers the JSON format as jsonl (JSON Lines, one object per row) rather than json, so the flag maps to that adapter - same scripting use case as the one in the issue. Happy to adjust if you'd prefer different flag/format semantics.
Activity
leo7martins commentedon Nov 21, 2026
I've opened #275 for this.
It turned out
cli_helpersregisters the JSON format asjsonl(JSON Lines, one object per row) rather thanjson, so the flag maps to that adapter - same scripting use case as the one in the issue. Happy to adjust if you'd prefer different flag/format semantics.