This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Use Playwright to test UI by snapshot.
- Before creating a PR, run
npm testlocally to ensure all Playwright tests pass.
Super JSON Editor is a sophisticated standalone web application that parses, edits, and reconstructs deeply nested/escaped JSON structures. The application is built as a single HTML file with embedded JavaScript and CSS, utilizing Monaco Editor for a professional IDE-like experience.
The application features a three-panel layout with multi-document support:
- Input Panel (left) - Accepts raw JSON input, fully editable with syntax highlighting
- Layer Editor (middle) - Dynamic multi-tab interface for editing each JSON layer with bidirectional synchronization
- Output Panel (right) - Displays final reconstructed JSON result, read-only
- Multi-document support - Work with multiple JSON documents simultaneously via main tabs
- No automatic syncing between sections - Input, Layer Editor, and Output are independent by design
- Two primary action buttons: "Parse" and "Apply"
- Bidirectional tab sync - Changes in any layer tab automatically update related parent/child tabs
- Explicit workflow - User-controlled flow: Input → Analyze → Edit Layers → Generate → Output
- Auto-save functionality - All documents and states are automatically saved to localStorage
-
JSONLayerAnalyzer Class (lines 672-755)
- Recursively analyzes and detects multiple layers of escaped JSON
- Parses strings that contain JSON objects/arrays
- Rebuilds nested JSON structures after editing
- Tracks parent-child relationships between layers
- Supports configurable max depth (default: 10 layers)
-
Document Management System (lines 757-886)
- Multi-document support with unique IDs
- Automatic state preservation across sessions
- Tab-based document switching with optimized performance
- In-place title editing via double-click
- Document close functionality with automatic fallback
-
Monaco Editor Integration (lines 1087-1155)
- Three primary editors: input, output, and dynamic layer editors
- VS Code's Monaco Editor for professional editing experience
- Auto-formatting, real-time validation, and syntax highlighting
- Configurable font size and line numbers
- Word wrap and paste formatting
-
Layer Management System (lines 1199-1252)
- Dynamic tab generation for each detected JSON layer
- Lazy loading of layer editors for performance
- Independent editing of each layer
- Automatic bidirectional synchronization between layers
- Parent-child relationship tracking
-
Performance Optimizations
- Debounced save operations (300ms delay)
- Lazy editor creation (only when tab is viewed)
- DOM element caching for tabs
- Batch DOM updates
- RequestAnimationFrame for non-blocking UI updates
analyzeJSON()(lines 1158-1196): Main entry point for parsing multi-layer JSONgenerateOutput()(lines 1582-1616): Produces final JSON output from edited layersrebuildFromLayers()(lines 1505-1555): Reconstructs nested JSON from edited layers
createDocument()(lines 758-770): Creates new document with unique IDswitchToDocument()(lines 778-830): Optimized document switchingcloseDocument()(lines 847-885): Closes document with proper cleanuprenderMainTabs()(lines 891-920): Efficient tab rendering with caching
generateEditTabs()(lines 1199-1252): Creates UI tabs for each detected layercreateLayerEditor()(lines 1254-1291): Lazy creation of Monaco editorshandleLayerEdit()(lines 1319-1352): Processes layer edits with syncupdateChildLayers()(lines 1355-1401): Propagates changes to child layersupdateParentLayers()(lines 1404-1448): Propagates changes to parent layers
debounce()(lines 659-669): Performance utility for throttling operationssaveDocumentsToStorage()(lines 1028-1054): Auto-save with visual feedbackloadDocumentsFromStorage()(lines 1056-1084): Restore session stateshowNotification()(lines 1683-1692): User feedback system
- Multi-layer JSON parsing - Handles infinite nested escaped JSON strings
- Multi-document tabs - Work with multiple JSON documents simultaneously
- Bidirectional sync - Real-time synchronization between parent and child layers
- Auto-save - Automatic persistence to localStorage with visual feedback
- Keyboard shortcuts - Productivity shortcuts for common operations
- Resizable panels - Adjustable panel widths for optimal workspace
- Real-time validation - Instant JSON syntax validation
- Lazy loading - Editors created only when needed for performance
- Smart analysis - Intelligent detection of JSON structures within strings
- Apply output to input - Quick workflow for iterative processing
Ctrl+Enter- Analyze JSONCtrl+S- Generate OutputCtrl+T- New DocumentCtrl+W- Close Current DocumentCtrl+Tab- Switch to Next Document
- Single File Design - All functionality in one HTML file for simplicity
- No Build System - Direct browser execution without compilation
- Progressive Enhancement - Features load as needed
- Performance First - Optimized for large JSON structures
- Debounced save operations prevent excessive localStorage writes
- Lazy editor creation reduces initial load time
- DOM caching minimizes reflow/repaint operations
- Batch updates for better rendering performance
- RequestAnimationFrame for non-blocking updates
- Modern browser with ES6+ support
- Support for Monaco Editor (Chrome, Firefox, Safari, Edge)
- LocalStorage API availability
- Template literals and arrow functions
Edit the single index.html file directly. Follow existing patterns for:
- Event handling with proper cleanup
- Debouncing for performance-sensitive operations
- Proper editor disposal to prevent memory leaks
- LocalStorage integration for persistence
Use browser developer tools to monitor:
parsedLayers- Current layer state arrayeditors- Active Monaco editor instancesdocuments- All open documentscurrentDocId- Active document identifier- Performance tab for render performance
- Network tab for Monaco Editor CDN loading
- Open index.html in browser
- Use sample nested JSON data
- Test layer detection and editing
- Verify bidirectional sync
- Test document management
- Check auto-save functionality
Input Editor → Smart Analysis → Layer Detection → Layer Editors
↓ ↓ ↓ ↓
Auto-save Layer Mapping Parent-Child Bidirectional
↓ ↓ Relationships Sync
localStorage Parsed Layers ↓ ↓
↓ ↓ Rebuild Logic Real-time
Restoration Tab Creation ↓ Updates
↓ Output Gen ↓
Editor Creation ↓ Parent/Child
↓ Final JSON Updates
Lazy Loading
- Each layer maintains a
parentFieldproperty indicating its origin [parsed]indicates the entire parent is an escaped JSON string- Named fields indicate specific object properties containing escaped JSON
- Changes propagate bidirectionally through parent-child relationships
- Updates use an
isUpdatingflag to prevent circular updates - Editor positions and selections are preserved during updates
- Editors are properly disposed when switching documents or closing tabs
- Event listeners are cleaned up to prevent memory leaks
- DOM elements are reused where possible
- Maximum depth of 10 layers (configurable)
- Large JSON files may impact performance
- Browser localStorage size limits apply
- No server-side persistence