NDJSON Preview
A powerful VS Code extension for viewing and analyzing NDJSON (Newline Delimited JSON) files with syntax highlighting, filtering, and custom ordering capabilities.

Features
📊 Live Preview with Syntax Highlighting
- Side-by-side view: See pretty-printed JSON in a preview panel as you navigate through your NDJSON file
- Syntax highlighting: Color-coded JSON with distinct colors for keys, strings, numbers, booleans, and null values
- Auto-updates: Preview automatically updates as you move your cursor to different lines
- Line highlighting: Current line is highlighted in the editor for easy tracking
🔍 Advanced Filtering
- Filter by key-value pairs: Show only lines that match specific criteria
- Nested key support: Use dot notation (e.g.,
user.email, address.city) to filter on nested properties
- Multiple filters: Apply multiple filters with AND logic - lines must match all filters
- Filtered view: Creates a new editor tab showing only matching lines, perfect for large files
- Visual feedback: Shows count of matching lines (e.g., "Showing 45 of 1000 lines")
🔧 Custom JSON Ordering
- Reorder Keys toggle: Automatically sort JSON keys with primitives first, then objects/arrays
- Custom ordering: Define your own key order - specify which keys should appear first
- Persistent preferences: Custom order is saved globally and remembered between sessions
- Nested ordering: Ordering rules apply recursively to nested objects
Installation
From VSIX (Local Installation)
- Download the
.vsix file
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X / Cmd+Shift+X)
- Click the
... menu → "Install from VSIX..."
- Select the downloaded file
From VS Code Marketplace
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X / Cmd+Shift+X)
- Search for "NDJSON Preview"
- Click Install
Usage
Basic Usage
- Open an NDJSON file (
.ndjson or .jsonl)
- Preview opens automatically in a side panel
- Navigate lines - The preview updates as you move your cursor
Filtering Lines
- Click the "Filter" button in the preview panel
- Enter a key (e.g.,
status or user.name for nested keys)
- Enter the value to match
- Click "Add" or press Enter
- Add more filters if needed
- Click "Apply"
A new editor tab opens showing only lines that match all your filters. Click "Clear All" to remove filters and close the filtered view.
Example filters:
status = active - Show only lines where status equals "active"
user.role = admin - Show lines where user.role equals "admin"
- Multiple filters:
type = order AND status = completed
Custom Key Ordering
Using the Reorder Toggle
Click the "Reorder Keys" toggle to automatically organize JSON with:
- Primitive values (strings, numbers, booleans, null) first
- Objects and arrays last
Using Custom Order
- Click the "Custom Order" button
- Enter one key per line in your desired order:
id
name
email
status
- Click "Apply"
Keys will appear in the order you specified, followed by any remaining keys. This preference is saved globally.
Keyboard Shortcuts
In the filter modal:
- Enter in the key field - Move to value field
- Enter in the value field - Add the filter
- Esc - Close modal (click outside also works)
The extension works with NDJSON (Newline Delimited JSON) files where each line contains a valid JSON object:
{"id":1,"name":"Alice","age":30,"city":"New York","status":"active"}
{"id":2,"name":"Bob","age":25,"city":"Boston","status":"inactive"}
{"id":3,"name":"Charlie","age":35,"city":"Chicago","status":"active"}
Supported file extensions:
Configuration
Global Settings
- Custom Order: Saved globally in VS Code's global state
- Persists across sessions and workspaces
Per-Session Settings
- Filters: Reset when the preview panel is closed
- Reorder Keys toggle: Reset when the preview panel is closed
Use Cases
Log Analysis
Filter server logs by status code, user ID, or error type:
{"timestamp":"2024-01-15","level":"error","user_id":"123","message":"..."}
{"timestamp":"2024-01-15","level":"info","user_id":"456","message":"..."}
Filter: level = error to see only error logs
Data Exploration
Explore large datasets by filtering on specific attributes:
{"product":"laptop","category":"electronics","price":999,"stock":50}
{"product":"desk","category":"furniture","price":299,"stock":12}
Filter: category = electronics to view only electronics
API Response Analysis
Analyze API responses with consistent key ordering:
{"id":1,"data":{...},"metadata":{...},"status":"success"}
Custom order: id, status, data, metadata
- Efficient filtering: Handles files with thousands of lines
- Lazy rendering: Preview only renders the current line
- Lightweight: No heavy dependencies, uses VS Code's native capabilities
Development
Building from Source
# Clone the repository
git clone https://github.com/yourusername/ndjson-preview.git
cd ndjson-preview
# Install dependencies
npm install
# Compile
npm run compile
# Run in development mode (Press F5 in VS Code)
Project Structure
ndjson-preview/
├── src/
│ └── extension.ts # Main extension code
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
└── README.md # This file
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Known Issues
- Filtered view creates a new untitled document - changes to this document are not saved
- Very large JSON objects (>1MB per line) may cause performance issues in the preview
License
MIT
Release Notes
1.0.0
Initial release with:
- Live preview with syntax highlighting
- Line-by-line navigation
- Filter by key-value pairs
- Custom key ordering
- Nested key support with dot notation
- Persistent global preferences
Credits
- Built with pretty-print-json for syntax highlighting
- Developed for the VS Code community
Feedback & Support
Enjoy analyzing your NDJSON files! 🚀