Compare two documents and list what was added, removed and changed.
| Endpoint | POST https://astraljson.com/api/v1/json-compare |
| Auth | Bearer token, free |
| Sends | inputs: text[] |
| Returns | result: json |
| Price | Free. 1,000 calls a day, 60 a minute. |
A text diff of two JSON files reports a reformat as a change and a reordered object as a rewrite. This compares the structures, so a test that asserts on an API response, or a job watching a config for real drift, only fires when something actually moved.
For a one-off, the browser version needs no token and never sends your data anywhere: it runs on your own machine.
curl -X POST https://astraljson.com/api/v1/json-compare \
-H "Authorization: Bearer ast_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"inputs": ["{\"plan\":\"free\",\"limits\":{\"calls\":100}}","{\"limits\":{\"calls\":1000},\"plan\":\"free\",\"beta\":true}"]}'{
"tool": "json-compare",
"result": "{\n \"identical\": false,\n \"added\": 1,\n \"removed\": 0,\n \"changed\": 1,\n \"changes\": [\n {\n \"path\": \"beta\",\n \"type\": \"added\",\n \"after\": true\n },\n {\n \"path\": \"limits.calls\",\n \"type\": \"changed\",\n \"before\": 100,\n \"after\": 1000\n }\n ]\n}",
"chars": 276,
"ms": 1
}const res = await fetch("https://astraljson.com/api/v1/json-compare", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ASTRAL_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"inputs": ["{\"plan\":\"free\",\"limits\":{\"calls\":100}}","{\"limits\":{\"calls\":1000},\"plan\":\"free\",\"beta\":true}"]}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const { result } = await res.json();import os, requests
res = requests.post(
"https://astraljson.com/api/v1/json-compare",
headers={"Authorization": f"Bearer {os.environ['ASTRAL_TOKEN']}"},
json={"inputs": ["{\"plan\":\"free\",\"limits\":{\"calls\":100}}","{\"limits\":{\"calls\":1000},\"plan\":\"free\",\"beta\":true}"]},
timeout=30,
)
res.raise_for_status()
result = res.json()["result"]| Field | Type | Notes |
|---|---|---|
| inputs | string[] | Required. Between 2 and 20 items. Up to 200,000 characters per call. |
Errors are RFC 7807 problem documents with a stable type you can branch on.
| missing-token | 401 | No Authorization header. |
| bad-request | 400 | inputs missing or the wrong type. |
| tool-failed | 422 | The input could not be processed. detail says why. |
| quota-exceeded | 429 | Past 1,000 calls today. |
A token takes thirty seconds
Free, no card, 1,000 calls a day, and the same token works on astraltext.com, astralpdf.com, astraljson.com and astralbatch.com.
Get a free token