JSON Diff Tool
Compare two JSON objects and highlight differences. Perfect for debugging API changes and data transformations.
How to Use JSON Diff Tool
How to Use JSON Diff Tool
The JSON Diff Tool helps you compare two JSON objects side-by-side and identify all differences between them. Perfect for debugging API changes, comparing configurations, or validating data transformations.
Quick Start Guide
- Input JSON Objects: Paste or type your first JSON object in the "JSON 1" field and your second JSON object in the "JSON 2" field
- View Differences: The tool automatically compares the objects and displays:
- Added fields (green): Present in JSON 2 but not in JSON 1
- Removed fields (red): Present in JSON 1 but not in JSON 2
- Modified fields (orange): Present in both but with different values
- Unchanged fields: Fields with identical values (not shown in diff view)
- Use Actions: Swap inputs, copy diff results, or clear all fields as needed
Understanding JSON Comparison
What is JSON Diff?
JSON diff compares two JSON objects and identifies all differences between them. It performs deep comparison of nested structures and highlights additions, removals, and modifications.
Comparison Example:
JSON 1:
{
"user": {
"name": "John",
"age": 30,
"active": true
}
}
JSON 2:
{
"user": {
"name": "John",
"age": 31,
"email": "john@example.com"
}
}
Differences:
- Modified: user.age (30 β 31)
- Added: user.email
- Removed: user.active
Why Compare JSON?
- Debug API changes
- Validate data transformations
- Track configuration changes
- Verify migrations
- Document schema evolution
Common Use Cases
1. API Version Comparison
Scenario: Compare responses from v1 and v2 API.
JSON 1 (v1 response):
{
"id": 123,
"username": "alice",
"created": "2024-01-15"
}
JSON 2 (v2 response):
{
"id": 123,
"username": "alice",
"email": "alice@example.com",
"created_at": "2024-01-15T10:30:00Z"
}
Differences:
- Added: email
- Added: created_at
- Removed: created
Benefit: Quickly identify breaking changes between API versions.
2. Configuration Validation
Scenario: Compare development and production configs.
JSON 1 (development):
{
"database": {
"host": "localhost",
"debug": true
}
}
JSON 2 (production):
{
"database": {
"host": "prod.example.com",
"debug": false
}
}
Differences:
- Modified: database.host
- Modified: database.debug
Benefit: Ensure correct settings for each environment.
3. Data Migration Verification
Scenario: Verify data transformation after migration.
JSON 1 (before migration):
{
"product": {
"price": "99.99",
"stock": "50"
}
}
JSON 2 (after migration):
{
"product": {
"price": 99.99,
"stock": 50
}
}
Differences:
- Modified: product.price (string β number)
- Modified: product.stock (string β number)
Benefit: Confirm type conversions and data integrity.
4. Schema Evolution Tracking
Scenario: Track changes in data schema over time.
JSON 1 (old schema):
{
"user": {
"name": "Bob",
"role": "admin"
}
}
JSON 2 (new schema):
{
"user": {
"firstName": "Bob",
"lastName": "Smith",
"roles": ["admin", "editor"]
}
}
Differences:
- Added: user.firstName, user.lastName, user.roles
- Removed: user.name, user.role
Benefit: Document schema changes for team awareness.
5. Testing API Responses
Scenario: Validate API response matches expected structure.
JSON 1 (expected):
{
"status": "success",
"data": {
"count": 10
}
}
JSON 2 (actual):
{
"status": "success",
"data": {
"count": 10,
"total": 100
}
}
Differences:
- Added: data.total
Benefit: Identify unexpected fields in API responses.
6. Debugging State Changes
Scenario: Compare application state before and after action.
JSON 1 (before):
{
"cart": {
"items": [],
"total": 0
}
}
JSON 2 (after):
{
"cart": {
"items": [{"id": 1, "qty": 2}],
"total": 39.98
}
}
Differences:
- Modified: cart.items (empty β has items)
- Modified: cart.total (0 β 39.98)
Benefit: Track exactly what changed during user interaction.
Features
Deep Comparison
- Compares nested objects at all levels
- Shows full path to each difference
- Handles complex data structures
- Preserves context
Color-Coded Results
- Green: Added fields
- Red: Removed fields
- Orange: Modified fields
- Gray: Unchanged fields
Statistics Dashboard
- Added count
- Removed count
- Modified count
- Unchanged count
Actions
- Swap: Reverse comparison direction
- Copy Diff: Export differences as text
- Clear: Reset all inputs
Examples
- Simple Change: Basic value modifications
- Added Fields: New properties
- Removed Fields: Deleted properties
- Nested Changes: Deep object differences
Technical Details
Comparison Algorithm:
Recursively traverses both objects and compares:
function compareObjects(obj1, obj2, path = ') {
const keys1 = new Set(Object.keys(obj1 || {}))
const keys2 = new Set(Object.keys(obj2 || {}))
const allKeys = new Set([...keys1, ...keys2])
allKeys.forEach(key => {
const currentPath = path ? `${path}.${key}` : key
const val1 = obj1?.[key]
const val2 = obj2?.[key]
if (!keys1.has(key)) {
// Added in obj2
} else if (!keys2.has(key)) {
// Removed from obj1
} else if (isObject(val1) && isObject(val2)) {
// Recurse for nested objects
compareObjects(val1, val2, currentPath)
} else if (val1 !== val2) {
// Modified value
}
})
}
Path Notation:
Differences use dot notation for nested paths:
user.nameβ Top-level user object, name propertysettings.theme.colorβ Three levels deepitems.0.priceβ Array element at index 0
Type Handling:
All JSON types are supported:
- Objects: Deep comparison
- Arrays: Value comparison
- Strings: Direct comparison
- Numbers: Direct comparison
- Booleans: Direct comparison
- Null: Direct comparison
Array Comparison:
Arrays are compared as complete values:
[1, 2, 3]vs[1, 2, 3]β Unchanged[1, 2, 3]vs[1, 2, 4]β Modified- Both old and new values shown for modified arrays
Best Practices
Choosing Comparison Direction:
Left to Right (JSON 1 β JSON 2):
- Compare old version to new version
- Show what's been added/removed
- Track forward changes
Right to Left (JSON 2 β JSON 1):
- Compare new version to old version
- Show what needs to be added back
- Track backward changes
Use the Swap button to quickly reverse direction.
Interpreting Results:
Added Fields (Green):
- New features in JSON 2
- Additional data
- Schema expansion
Removed Fields (Red):
- Deprecated features
- Data cleanup
- Schema reduction
Modified Fields (Orange):
- Updated values
- Type changes
- Data transformations
Unchanged Fields (Gray):
- Stable properties
- Consistent data
- No action needed
Performance Considerations:
Fast Comparison:
- Objects up to 10,000 keys
- Handles deep nesting (100+ levels)
- Minimal memory overhead
- Real-time updates
Large Objects:
- May take 1-2 seconds for very large JSON
- Consider breaking into smaller chunks
- Focus on specific subtrees if possible
Troubleshooting
Issue: "Invalid JSON" error
Solution: Ensure both inputs are valid JSON. Common mistakes:
- Missing quotes around property names
- Trailing commas
- Single quotes instead of double quotes
- Unescaped special characters
Issue: Too many differences shown
Solution: You may be comparing completely different objects. Verify:
- Both JSONs represent similar data
- Structure is roughly the same
- You haven't swapped unrelated objects
Issue: Arrays showing as modified when they look the same
Solution: Arrays are compared by value. Check:
- Element order (must be identical)
- Data types (["1"] vs [1])
- Hidden whitespace or special characters
Issue: Nested objects not expanding
Solution: The tool shows full paths. Look for:
- Dot notation in paths (user.profile.name)
- All nested differences listed separately
- Each level shown as individual item
Issue: Performance is slow
Solution: Large objects may take time. Try:
- Breaking JSON into smaller chunks
- Comparing specific sections
- Using browser with better JavaScript performance
Browser Compatibility
This tool works in all modern browsers:
- β Chrome/Edge (latest)
- β Firefox (latest)
- β Safari (latest)
- β Opera (latest)
Required Features:
- JavaScript enabled
- Clipboard API (for copy functionality)
Privacy & Security
Client-Side Processing:
All comparisons happen entirely in your browser. Your JSON data:
- Never leaves your device
- Is not sent to any server
- Is not logged or stored
- Disappears when you close/refresh the page
Safe for Sensitive Data:
You can safely compare:
- API responses with tokens
- Configuration files with credentials
- User data with PII
- Proprietary data structures
- Internal schemas
Advanced Use Cases
1. Automated Testing
Compare expected vs actual API responses:
// Expected
{"status": "success", "count": 10}
// Actual
{"status": "success", "count": 10, "cached": true}
// Diff shows unexpected "cached" field
2. Database Schema Changes
Track database document changes:
// Before
{"_id": "123", "name": "Product"}
// After
{"_id": "123", "name": "Product", "tags": []}
// New "tags" field added
3. Feature Flag Validation
Compare feature flag configurations:
// Staging
{"featureX": true, "featureY": false}
// Production
{"featureX": false, "featureY": false}
// featureX differs between environments
4. Contract Testing
Verify API contract compliance:
// Contract
{"id": "number", "name": "string"}
// Response
{"id": 123, "name": "Test", "extra": "field"}
// Unexpected "extra" field
5. Data Synchronization
Compare source and target after sync:
// Source
{"updated": "2024-01-15", "version": 2}
// Target
{"updated": "2024-01-14", "version": 1}
// Sync incomplete - versions differ
6. Monitoring Changes
Track changes in external APIs:
// Last week
{"endpoints": ["/api/v1/users"]}
// This week
{"endpoints": ["/api/v1/users", "/api/v2/users"]}
// New v2 endpoint added
Real-World Examples
E-commerce Order:
Before Processing:
{
"order": {
"id": 1001,
"status": "pending",
"items": 3,
"total": 150.00
}
}
After Processing:
{
"order": {
"id": 1001,
"status": "shipped",
"items": 3,
"total": 150.00,
"tracking": "ABC123"
}
}
Differences:
- Modified: order.status (pending β shipped)
- Added: order.tracking
User Profile Update:
Original:
{
"user": {
"email": "old@example.com",
"verified": false,
"preferences": {
"theme": "light"
}
}
}
Updated:
{
"user": {
"email": "new@example.com",
"verified": true,
"preferences": {
"theme": "dark",
"language": "en"
}
}
}
Differences:
- Modified: user.email
- Modified: user.verified
- Modified: user.preferences.theme
- Added: user.preferences.language
Tips & Tricks
- Use Examples: Click example buttons to see comparison patterns
- Swap to Compare: Use Swap to reverse comparison direction
- Copy Results: Export diff for documentation or reports
- Validate JSON: Tool checks JSON syntax automatically
- Check Statistics: Review counts before diving into details
- Focus on Color: Green/red/orange quickly show change types
- Path Navigation: Use dot notation to locate nested changes
- Test Migrations: Compare before/after for data transformations
- Track Versions: Compare API responses across versions
- Document Changes: Copy diff for change logs or documentation
Common Patterns
API Response Pattern:
Modified: data.version (1 β 2)
Added: data.newFeature
Removed: data.deprecatedField
Configuration Pattern:
Modified: database.host (localhost β production.db)
Modified: debug (true β false)
Added: cache.ttl
Schema Evolution Pattern:
Added: user.email
Added: user.role
Removed: user.legacy_field
Modified: user.id (string β number)
Frequently Asked Questions
Most Viewed Tools
Screen Size Converter
Calculate screen width and height from diagonal size and aspect ratio. Convert between inches and centimeters for displays, TVs, and monitors with instant dimension calculations.
Use Tool βDPI Calculator
Calculate DPI (dots per inch), image dimensions, and print sizes. Convert between pixels and physical dimensions for printing and displays.
Use Tool βPaper Size Converter
Convert between international paper sizes (A4, Letter, Legal) with dimensions in mm, cm, and inches. Compare ISO A/B series and North American paper standards.
Use Tool βFuel Consumption Converter
Convert between MPG (miles per gallon), L/100km (liters per 100 kilometers), and other fuel efficiency units. Compare car fuel economy across different measurement systems.
Use Tool βCSV Splitter
Split large CSV files into smaller files by number of rows. Process large datasets in manageable chunks instantly.
Use Tool βProduct Schema Generator
Generate JSON-LD Product schema markup for SEO. Add product details like name, price, brand, rating, and availability to create structured data for rich search results.
Use Tool βLarge Text File Viewer
View and search large text files up to 200MB in your browser. Features virtual scrolling, line numbers, search functionality, and file statistics. Perfect for log files, CSV, JSON, and code files.
Use Tool βAPI Key Generator
Generate secure, cryptographically random API keys for authentication and authorization. Create custom API keys with various formats including hex, base64, and prefixed keys.
Use Tool βRelated Development Tools
JSON Formatter & Validator
FeaturedFormat, validate, and pretty-print JSON with our developer-friendly editor.
Use Tool βQR Code Generator
FeaturedCreate custom QR codes for URLs, text, and contact info
Use Tool βHTML Validator
Validate HTML markup and check for common issues. Detect missing attributes, accessibility problems, deprecated tags, and structure errors. Free and runs entirely in your browser.
Use Tool βCSV Null Value Handler
Handle null and empty values in CSV - Replace, remove, or keep missing data with flexible null handling strategies
Use Tool βCSV Data Type Converter
Convert data types in CSV - Transform CSV column values to numbers, booleans, dates with automatic type detection and cleaning
Use Tool βCSV to Excel Converter
Convert CSV to Excel - Transform comma-separated values to Excel spreadsheet with auto-width columns
Use Tool βTSV to CSV Converter
Convert TSV to CSV - Transform tab-separated values to comma-separated values with automatic quoting
Use Tool βSlug Generator
Generate URL-friendly slugs from any text. Create SEO-optimized slugs for blog posts, products, and web pages instantly.
Use Tool βShare Your Feedback
Help us improve this tool by sharing your experience