How devgroves/bigjsontool works
Purpose and Runtime
Next.js App Router application for viewing and querying multi-GB JSON without loading the complete document in the browser or Node heap. The main UI is client-driven and API routes are dynamic. Raw files and derived metadata/indexes live under the OS temp directory; Next runs the UI/API process.
Entry points: app/page.tsx, app/layout.tsx, app/api/json-level/route.ts, app/api/json-query/route.ts.
Import and File Registration Pipeline
Files receive UUID IDs and are persisted as raw .bin files plus metadata. Three ingestion paths support generated streaming JSON, multipart upload, and remote-URL import. URL imports stream to disk and expose index-build progress through SSE.
Core routes: app/api/stream-json/route.ts, app/api/upload/route.ts, app/api/import-url/route.ts, app/api/import-index-stream/route.ts.
Storage and remote-file abstractions: app/lib/uploadStore.ts, app/lib/remoteFileStore.ts.
Local Byte-Offset Indexing
The local fallback is a byte-oriented, streaming indexer. It records root keys and container spans through depth 3, enabling direct range reads and bounded subtree parsing rather than full-document deserialization. Index data is persisted alongside the raw file and rebuilt when necessary.
Core implementation: app/lib/buildIndex.ts, app/lib/BuildIndexStream.ts, app/lib/splitConfig.ts.
/api/json-level resolves a requested path via an exact indexed container, an indexed ancestor walk, root-key offset, or finally a streaming full-file parse.
Splitter / Manifest Boundary
For large remote imports, an optional pyjson-splitter service splits root-level values into chunk files. A Fastify service serves chunks and subpaths. The application registers and reads a manifest that maps root keys to chunks, array ranges, and types; this path is preferred over local indexing.
Integration boundary: app/api/register-manifest/route.ts, app/lib/manifestFileStore.ts, app/lib/manifestJsonValue.ts.
External services: pyjson-splitter on localhost:8000 and Fastify chunk serving on localhost:4000. Their unavailability causes fallback to the local offset index / stream parsing path.
Tree Data Resolution and Pagination
GET /api/json-level produces a depth-limited subtree for the tree pane. Manifest-backed arrays are sliced across chunk boundaries; objects merge disjoint chunk subsets; scalars load from one chunk. Local files use byte spans and stream parsing. Returned deep containers become truncation markers, and arrays are paged in small previews.
Server endpoint: app/api/json-level/route.ts.
Client renderer and expansion controller: app/components/JsonTreeView.tsx.
Manifest resolution: app/lib/manifestJsonValue.ts.
JSONPath Query Execution
POST /api/json-query resolves the root key first, then applies the remaining JSONPath expression against only relevant data. Manifest arrays support positional windows, filters, and projection/descent over fetched items; chunk range metadata allows reads crossing chunk boundaries without loading whole arrays. Objects may require all chunks for that root object; local fallback uses indexed spans or streaming parsing.
Primary paths: app/api/json-query/route.ts, app/lib/manifestJsonValue.ts, app/lib/manifestFileStore.ts.
Browser Viewer and Byte Windows
The split-pane UI separates raw text access from structured navigation. The text component virtualizes fixed-width rows and fetches byte windows on demand; it does not accumulate the file client-side. The JSON tree performs incremental subtree and query requests, splicing expanded results into its current view.
UI paths: app/page.tsx, app/components/VirtualTextArea.tsx, app/components/JsonTreeView.tsx, app/components/JsonEditor.tsx.
Supporting APIs: app/api/file-chars/route.ts, app/api/stream-file/route.ts.
Main entry points: splitConfig.ts Local resolver · manifestJsonValue.ts Manifest value resolver · uploadStore.ts Raw file store · page.tsx Viewer page
Components 18
Browser Viewer
- Viewer page · Coordinates raw-text and tree panes.
app/page.tsx - Virtual text area · Requests byte windows without retaining the full file.
app/components/VirtualTextArea.tsx - JSON tree view · Expands subtrees and applies query results in place.
app/components/JsonTreeView.tsx - JSON editor
app/components/JsonEditor.tsx
Next.js API
- File character API
app/api/file-chars/route.ts - File stream API
app/api/stream-file/route.ts - JSON level API · Returns depth-limited, paged tree data and truncation markers.
app/api/json-level/route.ts - JSON query API · Resolves a root key before querying relevant data.
app/api/json-query/route.ts - Ingestion routes · Registers UUID-backed raw files; URL import reports indexing progress by SSE.
app/api/import-url/route.ts - Manifest registration API
app/api/register-manifest/route.ts
Local File Path
- Raw file store · Persists UUID metadata and raw .bin files in OS temp storage.
app/lib/uploadStore.ts - Byte-offset index · Stores root keys and depth-3 container spans beside raw files.
app/lib/buildIndex.ts - Index build stream
app/lib/BuildIndexStream.ts - Local resolver · Uses exact spans, ancestor spans, root offsets, then full-file streaming parse.
app/lib/splitConfig.ts
Remote Split Path
- Manifest store · Maps root keys to chunk files, ranges, and value types.
app/lib/manifestFileStore.ts - Manifest value resolver · Slices arrays across chunks, merges object subsets, and loads scalars.
app/lib/manifestJsonValue.ts - pyjson-splitter · Optionally splits remote root-level values into chunks.
- Fastify chunk server · Serves chunk files and subpaths.
Connections 23
- Viewer page → Virtual text area: renders
- Viewer page → JSON tree view: renders
- Viewer page → JSON editor: renders
- Virtual text area → File character API: fetches windows
- Virtual text area → File stream API: streams raw text
- JSON tree view → JSON level API: expands paths
- JSON tree view → JSON query API: submits JSONPath
- Ingestion routes → Raw file store: persists raw files
- Ingestion routes → Index build stream: builds index
- Index build stream → Byte-offset index: writes spans
- File character API → Raw file store: reads byte range
- File stream API → Raw file store: streams file
- JSON level API → Manifest value resolver: prefers manifest
- JSON query API → Manifest value resolver: queries relevant chunks
- JSON level API → Local resolver: falls back
- JSON query API → Local resolver: falls back
- Local resolver → Byte-offset index: uses spans
- Local resolver → Raw file store: range reads / parses
- Manifest registration API → Manifest store: stores manifest
- Manifest value resolver → Manifest store: reads ranges
- Manifest value resolver → Fastify chunk server: fetches chunks
- Ingestion routes → pyjson-splitter: optional remote split
- pyjson-splitter → Fastify chunk server: produces served chunks