# jsonl-tui
Explore JSONL (newline-delimited JSON) files in your terminal.
Point it at a file — it discovers every field (nested ones too), shows the
data as a table, and lets you **search, filter, sort, group and export** with
the keyboard or mouse. Your view layout is saved and restored automatically.
```
┌ Search [/] ─────────┐┌ Filter [f] ─────────┐┌ Group by [g] ───────┐
├ Fields ─────────────┤┌ Records ─────────────────────────────────────┐
│ [x] type 100% str ││ type price ▲ user.id user.name │
│ [x] price 92% str ││ order 143 $ 42 ada │
│ [ ] tags 100% arr ││ order $962 7 bob │
├ Active columns ─────┤│ refund 1.787,00 € 3 eve │
│ 1. type ││ ... │
│ 2. price ▲ ││ │
└─────────────────────┘└──────────────────────────────────────────────┘
## Install
**Prebuilt binary (Linux x86_64):**
```sh
curl -L https://github.com/OWNER/jsonl-tui/releases/latest/download/jsonl-tui-x86_64-unknown-linux-musl.tar.gz | tar xz
sudo mv jsonl-tui /usr/local/bin/
```
(The `musl` build is fully static and runs on any distro; a `gnu` build is
also attached to each release.)
**With cargo:**
```sh
cargo install jsonl-tui
```
**From source:**
```sh
git clone https://github.com/OWNER/jsonl-tui && cd jsonl-tui
cargo install --path .
```
## Usage
```sh
jsonl-tui data.jsonl
```
Headless mode for scripts/CI — apply filters and export without the UI:
```sh
jsonl-tui data.jsonl --filter "status=error score>3" --export out.jsonl
# Wrote 1,532 records to out.jsonl
```
| `--filter "<expr>"` | filter expression (see below) |
| `--search <text>` | substring search, or `re:pattern` for regex |
| `--group field[=value]` | group by a field, optionally pick one value |
| `--export <path>` | write the result as JSONL and exit |
| `--profile <name>` | start with a saved view profile |
| `--max-lines <n>` | cap how many records are loaded |
| `--no-mouse` | disable mouse support |
## Keys
| `/` `f` `g` | search / filter / group |
| `Tab` | cycle panels |
| `Space` | toggle a field as a column (in the field tree) |
| `[` `]` | reorder the selected column |
| `←` `→` then `s` | pick a column and sort by it (repeat = flip direction) |
| `Enter` | open row detail (pretty-printed original JSON) |
| `Esc` | close modal / clear input |
| `Ctrl+S` / `Ctrl+L` | save / load a view profile |
| `Ctrl+E` | export the current result to a JSONL file |
| `Ctrl+R` | reset search/filter/group/sort |
| `q` | quit |
**Mouse:** click headers to sort, rows to select (again for detail), fields to
toggle columns, facets to filter; the wheel scrolls any panel. Hold `Shift`
for the terminal's own text selection. Overflowing panels show a scrollbar.
## Filters
Space-separated clauses, all must match:
```
status=error score>3 name!=bob price<=100 msg~^time.*out field=null
```
Operators: `=` `!=` `>` `<` `>=` `<=` and `~` (regex). Nested fields use
dotted paths (`user.id=7`).
Comparisons are numeric whenever possible — **even inside messy strings**:
`"1 000 $"`, `"239129 EURO"`, `"$1,234.56"`, `"1.234,56 €"`, `"1'000'000"`
all compare (and sort) by their numeric value. `null` sorts last, matches
`field=null`, and never satisfies range comparisons.
## View profiles
`Ctrl+S` saves your columns (and their order), sort, group and search/filter
as a TOML file under `~/.config/jsonl-tui/`. It is re-applied automatically
the next time you open a file with the same fields — or explicitly with
`--profile <name>`. Files are plain TOML, safe to hand-edit.
## Notes
- Everything is loaded into memory and flattened once; search/filter/sort
operate on indices, so they stay fast while you type.
- Rendering caps at 2,000 rows, but filtering/sorting/**export always cover
the full dataset** (the status bar shows both numbers).
- Arrays of objects expand as `items[0].id`, … capped at 5 elements; scalar
arrays stay whole. For files too big for memory, use `--max-lines` (a
streaming/indexed mode is a possible future improvement).
## Development
```sh
cargo test # flattening, filters, sorting, config, export, mouse hit-testing
cargo clippy --all-targets -- -D warnings
```
Releases are automated: bump `version` in `Cargo.toml` and push to `main` —
CI tests, publishes to crates.io and attaches Linux binaries to a GitHub
release. Requires the `CARGO_REGISTRY_TOKEN` repository secret.
## License
MIT