How evg4b/modern-json-formatter works
Modern JSON Formatter is a browser extension that detects JSON in a page, presents an interactive formatted view, and supports jq queries, downloads, and configurable behavior. The main path runs from a browser page through the content-script extension and viewer, which uses background messaging for formatting, queries, history, and downloads; a Rust/WASM engine provides JSON operations. Options and FAQ are separate user-facing branches. Relationships for unsampled subsystems are limited to those explicitly documented in the README or shown in the source index.
Main entry points: query.rs jq Query Engine · handler.ts Background Dispatcher · extension.ts Page Integration · query-input.ts jq Query Input
Components 25
Page Viewer
- Page Integration
src/content-script/extension.ts - JSON Document
src/content-script/document/json-document.ts - JSON DOM Builder
src/content-script/dom/build-dom.ts - Formatter Viewer
src/content-script/ui/container/container.ts - jq Query Input
src/content-script/ui/query-input/query-input.ts - Query Undo History
src/content-script/ui/query-input/history-manager.ts - Query Autocomplete
src/content-script/ui/query-input/autocomplete.controller.ts
JSON Engine
- WASM API
worker-wasm/src/lib.rs - WASM Conversion
worker-wasm/src/convert.rs - JSON Parser
worker-wasm/core/src/parser.rs - jq Query Engine
worker-wasm/core/src/query.rs - jq Value Factory
worker-wasm/core/src/jaq_json_factory.rs - JSON Node Model
worker-wasm/core/src/node.rs - Number Hashing
worker-wasm/core/src/hash.rs - Value Conversion
worker-wasm/core/src/convert.rs
Background Services
- Background Dispatcher
src/background/handler.ts - Message Protocol
src/core/background/protocol.ts - Query History Store
src/background/history.ts - Download Service
src/background/download.ts
Settings and Help
- Options Page
src/options/options.ts - Option Controls
src/options/sections/download-mode-section.ts - FAQ
src/faq/faq.ts - FAQ Navigation
src/faq/sidebar/sidebar.controller.ts
Other components
- JSON Page
- Browser Runtime
Connections 25
- JSON Page → Page Integration: hosts script
README.md - Page Integration → JSON Document: uses document
src/content-script/extension.ts - Page Integration → JSON DOM Builder: uses builder
src/content-script/extension.ts - Page Integration → Formatter Viewer: mounts viewer
src/content-script/extension.ts - JSON Document → JSON DOM Builder: builds nodes
- Formatter Viewer → jq Query Input: renders query
- jq Query Input → Query Undo History: tracks edits
src/content-script/ui/query-input/query-input.ts - jq Query Input → Query Autocomplete: updates suggestions
src/content-script/ui/query-input/query-input.ts - jq Query Input → Background Dispatcher: submits query
- Query Autocomplete → Background Dispatcher: loads history
- Background Dispatcher → WASM API: calls JSON ops
src/background/handler.ts - Background Dispatcher → Query History Store: reads and writes
src/background/handler.ts - Background Dispatcher → Download Service: dispatches download
src/background/handler.ts - WASM API → WASM Conversion: converts values
worker-wasm/src/lib.rs - WASM API → jq Query Engine: runs jq
- jq Query Engine → JSON Parser: parses JSON
worker-wasm/core/src/query.rs - jq Query Engine → jq Value Factory: uses factory
worker-wasm/core/src/query.rs - jq Value Factory → JSON Parser: parses values
worker-wasm/core/src/jaq_json_factory.rs - jq Query Engine → JSON Node Model: builds nodes
worker-wasm/core/src/query.rs - jq Query Engine → Number Hashing: uses hashes
worker-wasm/core/src/query.rs - jq Query Engine → Value Conversion: converts values
worker-wasm/core/src/query.rs - Browser Runtime → Message Protocol: messaging host
- Options Page → Option Controls: renders controls
src/options/options.ts - Options Page → Background Dispatcher: manages history
- FAQ → FAQ Navigation: uses navigation
src/faq/faq.ts