Skip to content

Type to search extensions

JSONL LSP

v0.1.0

Language server for JSON Lines / NDJSON: per-record diagnostics, formatting, record outlines, hover inspection, and expand/compact code actions.

Updated 2 months ago
391 downloads 0 stars Repository ↗

jsonl-tools

Why this exists

LLM agents and web tools emit JSON Lines everywhere — transcripts, logs, tool output, eval results — but none of the editors I use supported the format as such: at best a .jsonl file gets mis-highlighted as JSON and flagged as one big syntax error. I especially wanted proper support in BBEdit, which is what I reach for to preview files. So: JSON Lines / NDJSON tooling built from a shared parsing core — a CLI, a Language Server Protocol server, and editor integrations that consume them. BBEdit is the first integration (a native compiled language module); the packages themselves are editor-neutral.

This project is fully vibe coded — written end to end by Claude.

Layout

  • packages/jsonl-core (@sarvagnan/jsonl-core): line-by-line JSONL parsing, validation diagnostics, and normalization
  • packages/jsonl-cli (@sarvagnan/jsonl-cli): command-line validation and formatting; installs the jsonl binary
  • packages/jsonl-lsp (@sarvagnan/jsonl-lsp): stdio LSP server for diagnostics and formatting, usable from any LSP-capable editor (BBEdit, Neovim, Helix, Zed, Emacs, …); installs the jsonl-lsp binary
  • editors/bbedit: BBEdit integration — compiled language module (syntax coloring, function menu with per-record summaries, Reformat Document, language guessing, LSP hookup) built against the official Bare Bones Language Module SDK, plus text filters
  • editors/zed: Zed extension — attaches jsonl-lsp (auto-installed from npm) to the JSON Lines language for diagnostics, formatting, record outlines, hover inspection, and code actions; requires the jsonl extension, which owns the language definition; see editors/zed/README.md

The packages are npm workspaces; everything below assumes npm install has been run once at the root (it wires up the cross-package symlinks).

Requirements: Node ≥ 20; the BBEdit module additionally needs macOS with the Xcode command line tools.

CLI

jsonl validate file.jsonl
jsonl format file.jsonl
jsonl format --check file.jsonl
jsonl normalize < input.jsonl > output.jsonl
jsonl pretty-record < selected-record.jsonl

During local development, run through Node directly:

node packages/jsonl-cli/bin/jsonl.js validate file.jsonl

By default, blank physical lines are invalid. Pass --allow-blank-lines to tolerate and skip them during normalization.

format prints normalized JSONL to stdout and does not modify files. format --check exits non-zero when input is invalid or not already normalized.

pretty-record expects exactly one selected JSONL record and prints expanded JSON for inspection.

Core API

import {
  normalizeJsonLines,
  parseJsonLines,
  validateJsonLines
} from "@sarvagnan/jsonl-core";

Diagnostics are reported with one-based line and column fields suitable for editor display.

LSP

jsonl-lsp --stdio

Initial capabilities:

  • textDocument/publishDiagnostics
  • textDocument/formatting
  • textDocument/rangeFormatting
  • textDocument/hover
  • textDocument/codeAction

The server accepts initialization options under jsonl:

{
  "jsonl": {
    "allowBlankLines": false,
    "finalNewline": "preserve"
  }
}

BBEdit

npm install                                             # once, at the root
cd editors/bbedit/module && make test && make install   # native language module
cd -
(cd packages/jsonl-cli && npm link)                     # jsonl on PATH
(cd packages/jsonl-lsp && npm link)                     # jsonl-lsp on PATH

Relaunch BBEdit and open any .jsonl file. See docs/bbedit-install.md for details, including the text filters.

Tests

npm install           # once, at the root
npm test              # workspace packages + editor filter scripts
npm run test:module   # compiled module: harness + reformat parity with the CLI
                      # (byte parity is over LF documents; in the editor the
                      # module preserves existing CR/CRLF line endings)
ZedExt An unofficial community project. Not affiliated with Zed Industries.

Data from Zed’s extension registry and GitHub · updated