JSON Diff & Compare

Compare two JSON objects side-by-side to highlight added, removed, and modified keys and values.

How to Compare JSON Objects

1

Input Both Payloads

Paste the baseline JSON on the left and the modified JSON on the right, or click Upload Left / Upload Right.

2

Automatic Instant Diff

Differences are calculated automatically in real time as you type, paste, or upload. Non-destructive AST parsing ignores formatting variations.

3

Analyze Differences

Review the diff summary badge counts and color-coded delta properties list, then click Copy Diff to export.

Tool Options

Added Keys (`+`)

Highlights newly introduced properties present in the modified payload but absent in the baseline JSON.

Removed Keys (`-`)

Highlights deleted properties present in the original baseline document but missing in the modified JSON.

Modified Values (`~`)

Highlights property keys that exist in both documents but contain modified scalar values or data types.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the JSON Diff Tool do?

The JSON Diff & Semantic Compare Tool analyzes two JSON payloads side-by-side, identifying added, removed, and modified keys and values. Executing 100% in-browser on blueutils.com, this tool parses both inputs into Abstract Syntax Trees (ASTs), allowing it to compare hierarchical objects semantically regardless of key ordering, whitespace differences, or line wrapping.

Whether verifying API contract upgrades, inspecting database schema migrations, diffing Kubernetes configs, or debugging state mutations, this tool provides:

  • Instant Client-Side Auto-Diffing: Automatically recalculates and highlights differences in real time as you type, paste, or upload files without requiring manual submit buttons.
  • Semantic AST Comparison: Matches properties by logical object paths rather than raw text line numbers, eliminating false positives caused by differing indentation or property ordering.
  • Color-Coded Delta Tags: Clean, compact visual badges detailing + ADD (green), - DEL (red), and ~ MOD (amber) changes with exact property paths.
  • Syntax Error Localization: Parses both baseline and target inputs against RFC 8259, highlighting the exact error line number in red if malformed JSON is supplied.

Core Concepts

Understanding semantic JSON diffing versus plain text diffing:

  1. Semantic Object Tree Diffing vs Text Line Diffing:
    • Standard line diff utilities (like diff or git diff) treat key reordering or changed indentation spacing as modifications. Semantic JSON comparison parses payloads into memory and matches keys recursively by dictionary identifier, accurately isolating true schema and value modifications.
  2. Delta Classification Categories:
    • + Added: A key or array index present in the modified JSON but absent in the baseline payload.
    • - Removed: A key or array index present in the baseline payload but missing in the modified JSON.
    • ~ Modified: A key existing in both objects whose primitive value, data type, or nested array length has changed.
    • Unchanged: Properties possessing identical values in both payloads.
  3. Data Privacy & In-Memory Execution:
    • 100% of object traversal and diff calculations execute inside your local browser engine. Sensitive API tokens, customer records, and private configurations never leave your machine.

How to use the tool?

  1. Load Both JSON Payloads:
    • Paste the baseline JSON into the left editor (Original JSON (Baseline)),
    • Paste the updated JSON into the right editor (Modified JSON (Target)), or
    • Use Upload Left / Upload Right to load local .json files, or click Sample to load a test comparison.
  2. Review Real-Time Diff Results:
    • Differences calculate automatically in real time.
    • If either input contains a syntax error, the line number in that editor's gutter highlights in red, accompanied by exact line and column diagnostics in the error alert.
    • The summary bar displays the total change count and color-coded delta metrics.
  3. Export Diff Summary:
    • Click Swap to reverse baseline and modified roles instantly.
    • Click Copy Diff to copy the formatted change report to your clipboard.

Related Developer Utilities

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/json/diff) for programmatic semantic JSON comparison in automated test suites, CI/CD validation scripts, and build pipelines.

API Request Parameters

Name Type Description Example
original / leftRaw String / Object Baseline JSON string or parsed JSON object. {"v": 1, "status": "ok"}
modified / rightRaw String / Object Target JSON string or parsed JSON object to compare against. {"v": 2, "status": "ok", "debug": true}

API Request Payload Examples

cURL (Using Direct JSON Objects)

curl -X POST https://blueutils.com/api/json/diff \
  -H "Content-Type: application/json" \
  -d '{
    "original": {
      "version": "1.0",
      "active": true
    },
    "modified": {
      "version": "1.1",
      "active": true,
      "newFeature": true
    }
  }'

cURL (Using Raw JSON Strings)

curl -X POST https://blueutils.com/api/json/diff \
  -H "Content-Type: application/json" \
  -d '{
    "original": "{\"version\": \"1.0\", \"active\": true}",
    "modified": "{\"version\": \"1.1\", \"active\": true, \"newFeature\": true}"
  }'

Python

import requests

url = "https://blueutils.com/api/json/diff"
# Pass either Python dictionaries or raw JSON strings
payload = {
    "original": {
        "version": "1.0",
        "active": True
    },
    "modified": {
        "version": "1.1",
        "active": True,
        "newFeature": True
    }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "original": "{\\"version\\": \\"1.0\\", \\"active\\": true}",
                "modified": "{\\"version\\": \\"1.1\\", \\"active\\": true, \\"newFeature\\": true}"
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/json/diff"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether both payloads were valid JSON. true
isIdentical Boolean true if payloads have identical keys and values. false
summary Object Change counts (added, removed, modified, unchanged, totalChanges). {"added":1,"removed":0,"modified":1,"unchanged":1,"totalChanges":2}
diffs Array Detailed array of difference items with path, type, and values. [{"type":"modified","path":"version","leftValue":"1.0","rightValue":"1.1"}]

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "message": "JSON differences found.",
  "isIdentical": false,
  "summary": {
    "added": 1,
    "removed": 0,
    "modified": 1,
    "unchanged": 1,
    "totalChanges": 2
  },
  "diffs": [
    {
      "type": "added",
      "path": "newFeature",
      "rightValue": true
    },
    {
      "type": "modified",
      "path": "version",
      "leftValue": "1.0",
      "rightValue": "1.1"
    }
  ]
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Original JSON Syntax Error: Unexpected token '}' at line 3 column 1"
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to diff JSON?

Automating semantic JSON diffing via API provides key engineering advantages:

  • Regression & Snapshot Testing: Compares API response payloads against saved fixture snapshots in CI/CD pipelines without getting tripped up by whitespace changes or timestamp key ordering.
  • Database Migration Audits: Verifies document schema transformations before and after database migrations to ensure zero unexpected data loss.
  • Config & State Verification: Tracks configuration drift across Kubernetes manifests, Terraform state files, and Helm release values.
  • Deterministic AI Validation: Validates whether structured model outputs match expected schemas without requiring expensive secondary LLM evaluation calls.

Native Usage

How to compare JSON files locally in code editors, terminal environments, or scripts:

Visual Studio Code & IDE Diffing

  • VS Code CLI: Run code --diff baseline.json modified.json
  • VS Code Explorer: Right-click first file → Select for Compare, right-click second file → Compare with Selected
  • JetBrains IDEs (IntelliJ / WebStorm): Select both files in tree → Ctrl + D (or Cmd + D)

Windows (CMD / PowerShell)

# Compare JSON files in PowerShell
Compare-Object -DifferenceObject (Get-Content new.json | ConvertFrom-Json) -ReferenceObject (Get-Content old.json | ConvertFrom-Json)

Linux / Unix (Bash)

# Using jq with diff
diff -u <(jq -S '.' old.json) <(jq -S '.' new.json)

Python

Using deepdiff or standard library in Python:

import json

def diff_keys(d1, d2, path=""):
    diffs = []
    for k in set(d1.keys()).union(d2.keys()):
        p = f"{path}.{k}" if path else k
        if k not in d1:
            diffs.append(f"+ Added {p}: {d2[k]}")
        elif k not in d2:
            diffs.append(f"- Removed {p}: {d1[k]}")
        elif d1[k] != d2[k]:
            diffs.append(f"~ Modified {p}: {d1[k]} -> {d2[k]}")
    return diffs

with open("old.json") as f1, open("new.json") as f2:
    print("\n".join(diff_keys(json.load(f1), json.load(f2))))

Java

Using standard JSON tree comparison in Java:

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;

public class JsonDiffExample {
    public static void main(String[] args) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode before = mapper.readTree(new File("old.json"));
        JsonNode after = mapper.readTree(new File("new.json"));

        boolean identical = before.equals(after);
        System.out.println("JSON files identical: " + identical);
    }
}

Frequently Asked Questions (FAQ)

What is semantic JSON diffing vs plain line diffing?

Plain text line diffs fail when JSON keys are re-ordered or formatted differently. Semantic JSON diffing parses both payloads into Abstract Syntax Trees to compare properties by logical path and value regardless of whitespace or key ordering.

Does this JSON diff tool ignore key ordering and formatting differences?

Yes. The JSON Diff parser extracts all object keys and compares values recursively, preventing false positive diff warnings caused by varying indentation or property order.

How do I compare two JSON files in VS Code?

In Visual Studio Code terminal, run code --diff baseline.json modified.json. In the file explorer, right-click the first file, choose Select for Compare, then right-click the second file and select Compare with Selected.

How to diff JSON files in the command line using jq or Linux diff?

In Linux/macOS Bash, sort keys and diff them directly using: diff -u <(jq -S . old.json) <(jq -S . new.json).

Is my JSON comparison data secure and private?

Yes. All JSON comparison calculations run 100% client-side inside your browser engine. Your JSON payloads and API responses are never transmitted across the network or stored on any server.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.