# Add JSONL and NDJSON support to tabular preview \(\#64471\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/d528c665e1a5c4627a68813435756592d9fad69d)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: d528c665e1a5c4627a68813435756592d9fad69d

Requested commit: d528c665e1a5c4627a68813435756592d9fad69d

Commit: d528c665e1a5c4627a68813435756592d9fad69d

Tree: ca93bde626c7afe2e4e365652683e532037d152f

Author: Ansh Dawda

Committer: GitHub

## Message

```
Add JSONL and NDJSON support to tabular preview (#64471)

## Objective

Extend the existing tabular preview to support `.jsonl` and `.ndjson`
files, making it easier to compare fields across records.

Discussed in https://github.com/zed-industries/zed/discussions/62917.

## Solution

Parse each nonblank line as a JSON object and reuse the existing table
preview. Top-level keys become columns in first-seen order, with new
keys from later records appended to the right.

- Preserve JSON values, including large numbers, without numeric
conversion.
- Display nested objects and arrays as compact JSON.
- Keep missing fields, `null`, `"null"`, and empty strings distinct.
- Show invalid-record errors with source line numbers and recover after
edits.
- Preserve sorting and filters unless column names or order change.
- Add JSONL/NDJSON to the existing preview shortcuts and document the
behavior.

Also fix a crash found during CSV regression testing: deleting rows
could leave the renderer using an old row mapping against shorter data.
Clear the mapping and virtual list together before recomputing them.

The preview remains read-only, accepts object records only, and uses the
existing text-based sorting and full-file parsing behavior.

## Testing

- All 20 tests in `tabular_data_preview` passed.
- The multiline CSV deletion regression passed across 20 scheduler
seeds.
- `cargo fmt -p tabular_data_preview -- --check` passed.
- `./script/clippy -p tabular_data_preview` passed.
- `cargo build -p zed --bin zed` passed.
- `git diff --check` passed.
- Manual QA on macOS, including retesting the reported CSV crash.

Windows and Linux were not tested locally. Large-file performance has
not been benchmarked.

To try it, open a `.jsonl` or `.ndjson` file and run `tabular data: open
preview` or `tabular data: open preview to the side`.

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

<img width="2358" height="1576" alt="image"
src="https://github.com/user-attachments/assets/8f7e7725-5a5c-465d-aa0a-d61cbb22d04f"
/>

The example shows source-order columns, fields introduced by later
records, nested values, and the distinction between missing values,
nulls, and strings.

Release Notes:

- Added JSONL and NDJSON support to the tabular data preview.

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
```

## Parents

- [5402570caab49d17f1849617c69039c63b99a17a](https://git.cafe/gitcafe/zed/commit/5402570caab49d17f1849617c69039c63b99a17a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/d528c665e1a5c4627a68813435756592d9fad69d?format=markdown)
