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:
- Semantic Object Tree Diffing vs Text Line Diffing:
- Standard line diff utilities (like
difforgit 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.
- Standard line diff utilities (like
- 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.
- 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?
- 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
.jsonfiles, or click Sample to load a test comparison.
- Paste the baseline JSON into the left editor (
- 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.
- 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
- JSON Formatter & Beautifier: Format and prettify JSON payloads with custom 2-space or 4-space indentation.
- JSON Minifier & Compressor: Compress JSON payloads by stripping non-essential whitespace.
- JSON Syntax Validator: Validate JSON syntax and inspect character offsets.
- JSON to YAML Converter: Convert JSON structures into clean YAML manifests.
- JSON Sorter: Sort JSON object keys alphabetically to produce canonical, deterministic structures.
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(orCmd + 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);
}
}