How to Open JSON Files: Complete Guide for All Platforms
Learn how to open and view JSON files on Windows, Mac, and Linux. Covers text editors, online tools, and specialized JSON viewers.
Emily Watson
• Technical Writer & Web DeveloperEmily is a web developer and technical writer with 6 years of experience covering JavaScript ecosystems, developer tooling, and data formats. She specialises in making complex technical concepts approachable for developers at all levels, with a particular focus on JSON fundamentals, formatting best practices, and the tools developers reach for every day.
Opening JSON Files
JSON files are plain text files, so they can be opened with any text editor. However, using the right tool makes a big difference.
Quick Methods by Platform
Windows
Notepad (Basic):- Right-click file → Open with → Notepad
- Right-click file → Open with Code
- Syntax highlighting and validation included
Mac
TextEdit:- Right-click → Open With → TextEdit
- Right-click → Open with → Visual Studio Code
Linux
# View in terminal
cat file.json
# Pretty print
cat file.json | python3 -m json.tool
# Open in editor
code file.json # VS Code
nano file.json # Nano
vim file.json # Vim
Best Tools for JSON
1. Visual Studio Code (Desktop)
Free cross-platform editor with:
- Syntax highlighting
- Auto-formatting (Shift+Alt+F)
- Error validation
- Extensions for JSON
2. Big JSON Viewer (Online)
Perfect for large files:
- No installation needed
- Handles 100MB+ files
- Tree view navigation
- Search functionality
- Share via URL
Visit bigjson.online
3. Browser
Simply drag a JSON file into Chrome/Firefox to view it formatted.
For Large JSON Files
Standard editors struggle with files over 100MB. Use:
Command Line Tools
jq (JSON Processor)
# Install
brew install jq # Mac
apt install jq # Ubuntu
# Pretty print
jq '.' file.json
# Colored output
jq -C '.' file.json
# Extract field
jq '.users[0].name' file.json
Python
# Built-in pretty print
python -m json.tool file.json
Editing JSON Files
VS Code shows errors in real-time with red underlines.
Troubleshooting
File Opens as Gibberish
The file might be compressed or encoded. Check the file extension.
Can't Open Large File
- Use Big JSON Viewer
- Use command line:
head -100 file.json - Split the file into smaller parts
Encoding Issues
# Check encoding
file -i yourfile.json
# Convert to UTF-8
iconv -f ISO-8859-1 -t UTF-8 input.json > output.json
Online Tools
Troubleshooting Common Issues
Corrupted JSON Files
# Check if file is valid JSON
jq empty file.json 2>&1
# Show first error
python3 -c "import json; json.load(open('file.json'))"
Common corruption patterns:
{"a":1,} - remove last comma{"text":"He said "hello""} needs backslashesFile Association Setup
Windows
# Set VS Code as default for .json files
ftype JSONFile="C:\Users\YourName\AppData\Local\Programs\Microsoft VS Code\Code.exe" "%1"
assoc .json=JSONFile
Mac
Linux
# Set default application
xdg-mime default code.desktop application/json
Streaming Huge Files
For files over 1GB that won't fit in memory:
JSONLines Format
# View first 10 records
head -10 huge.jsonl | jq '.'
# Search without loading full file
grep '"user_id":123' huge.jsonl | jq '.'
Stream with jq
# Process 10GB file without loading all at once
jq -c '.[]' huge.json | while read obj; do
echo $obj | jq '.name'
done
Python Streaming
import ijson
# Stream parse huge file
with open('huge.json', 'rb') as f:
objects = ijson.items(f, 'item')
for obj in objects:
print(obj['name']) # Process one at a time
IDE Comparison with Benchmarks
Performance Test (50MB JSON file)
| IDE | Load Time | Memory | Syntax Highlight | Validation |
|-----|-----------|--------|------------------|------------|
| VS Code | 0.8s | 180MB | ✅ | ✅ |
| Sublime Text | 0.3s | 95MB | ✅ | Plugin |
| IntelliJ IDEA | 1.5s | 320MB | ✅ | ✅ |
| Notepad++ | 0.5s | 65MB | ✅ | Plugin |
| Vim | 0.2s | 45MB | ✅ | Plugin |
Feature Comparison
VS Code (Best for most users):- Free, lightweight
- Real-time validation
- Auto-formatting (Shift+Alt+F)
- Extensions ecosystem
- Git integration
- Minimal memory usage
- Instant startup
- Great for quick edits
- Paid license ($99)
- Full IDE features
- Advanced refactoring
- Integrated debugging
- Heavy resource usage
- Browser-based, no install
- Handles 100MB+ files
- Tree navigation
- Search and filter
- URL sharing
Security Considerations
Untrusted JSON Files
⚠️ Never run JSON files as code:
// DANGEROUS - executes code
eval('(' + jsonString + ')');
// SAFE - only parses data
JSON.parse(jsonString);
Billion Laughs Attack
Carefully crafted JSON can cause denial of service:
{"a":"lol","b":"lollollol","c":"lollollollollollollollollol",...}
Protection:
import json
# Limit file size before parsing
MAX_SIZE = 10 1024 1024 # 10MB
with open('untrusted.json', 'rb') as f:
if f.seek(0, 2) > MAX_SIZE: # seek to end
raise ValueError("File too large")
f.seek(0)
data = json.load(f)
Sensitive Data
🔐 Never commit secrets to version control:
# Add to .gitignore
config.local.json
secrets.json
*.key.json
Use environment variables instead:
const config = {
apiKey: process.env.API_KEY, // Not hardcoded
database: process.env.DB_URL
};
Real-World File Scenarios
API Response Files
Save API responses for offline analysis:
# Fetch and save
curl https://api.github.com/users/octocat > github_user.json
# View formatted
jq '.' github_user.json
# Extract specific fields
jq '.name, .public_repos, .followers' github_user.json
Application Log Files
Parse structured logs:
# Filter errors from log
jq 'select(.level == "error")' app.log
# Count by error type
jq -s 'group_by(.error_code) | map({code: .[0].error_code, count: length})' app.log
Configuration Files
Edit app config safely:
# Backup first
cp config.json config.json.backup
# Edit with validation
code config.json
# Validate before deploying
jq empty config.json && echo "Valid JSON" || echo "Invalid JSON"
Package Metadata
Inspect package.json dependencies:
# List all dependencies
jq '.dependencies | keys' package.json
# Find specific version
jq '.dependencies.react' package.json
# Update version programmatically
jq '.version = "2.0.0"' package.json > package.json.tmp && mv package.json.tmp package.json
Advanced Viewing Techniques
Collapse/Expand Sections in VS Code
- Fold all: Ctrl+K Ctrl+0 (Windows) / ⌘+K ⌘+0 (Mac)
- Unfold all: Ctrl+K Ctrl+J / ⌘+K ⌘+J
- Fold level 2: Ctrl+K Ctrl+2 - Shows only 2 levels deep
Search Within JSON
# Find all email addresses
jq '.. | .email? // empty' users.json
# Recursive search for key
jq '.. | objects | select(has("user_id")) | .user_id' data.json
VS Code Extensions
Command Line Pro Tips
Pretty Print with Colors
# jq with colors (default in terminal)
jq -C '.' file.json | less -R
# Python with pygments
cat file.json | python -m json.tool | pygmentize -l json
Tail JSON Logs
# Watch log file for new entries
tail -f app.log | jq '.'
# Filter errors only
tail -f app.log | jq 'select(.level == "error")'
Compare Two JSON Files
# Show differences
diff <(jq -S '.' file1.json) <(jq -S '.' file2.json)
# Or use specialized tool
jd file1.json file2.json # JSON diff tool
Best Practices
jq empty file.jsoncp file.json file.json.backup)ls -lh file.json before openingPerformance Guidelines
| File Size | Recommended Tool | Load Time |
|-----------|------------------|------------|
| < 1MB | Any text editor | < 1s |
| 1-50MB | VS Code, Sublime | 1-3s |
| 50-100MB | Big JSON Viewer | 3-5s |
| 100MB-1GB | Big JSON Viewer, jq | 5-10s |
| > 1GB | jq streaming, ijson | Stream only |
Conclusion
For most users, VS Code for editing and Big JSON Viewer for viewing/analyzing covers all needs. For huge files over 1GB, use jq or ijson streaming to avoid loading the entire file into memory. Always validate JSON after editing to catch syntax errors early, and never commit sensitive credentials directly in JSON configuration files.
Related Articles
What is JSON? Complete Guide for Beginners 2026
Learn what JSON is, its syntax, data types, and use cases. A comprehensive beginner-friendly guide to understanding JavaScript Object Notation.
JSON File Explained: Structure, Extensions, and Best Practices
Comprehensive guide to JSON files - learn about .json extension, MIME types, structure, and how to create, open, and use JSON files effectively.
Best JSON Online Tools 2026: Viewers, Validators, and Formatters
Comprehensive guide to the best JSON online tools. Compare viewers, validators, formatters, and converters for working with JSON data.