Text and JSON Diff
Pricing
from $5.00 / 1,000 successful comparisons
Text and JSON Diff
Compare two texts (unified diff with line numbers) or two JSON documents (added, removed and changed paths), with summary counts. Standard library only. No network access and no scraping.
Pricing
from $5.00 / 1,000 successful comparisons
Rating
0.0
(0)
Developer
Brightwater Tools
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
12 days ago
Last modified
Categories
Security
Limited permissionsShare
Compare two texts or two JSON documents and see what changed. Paste the original and the new versions, pick a mode, and get the result.
The comparison code makes no outside requests, reads no files and does no scraping. It works only on the two inputs you paste in. The result is saved to your run's dataset on Apify.
$0.005 per successful comparison. Failed runs are not charged.
What you can do with it
- Check what changed between two versions of a config file, a spec or a list.
- Get a unified diff with line numbers for a code review or a ticket.
- Compare two JSON API responses and see which fields were added, removed or changed, with their paths (for example
$.parts[2].name).
How to use it
- Choose a mode:
textorjson. - Paste the original version into
old_textand the new version intonew_text. - Click Start. The result is saved as one item in the run's dataset on Apify.
Mode: text
Output fields: identical, old_lines, new_lines, added_lines, removed_lines, hunks and unified_diff.
- The
@@ -a,b +c,d @@headers inunified_diffgive the starting line and the number of lines in each text. context_linessets how many unchanged lines appear around each change (0 to 10, default 3). Use 0 to show only the changed lines.- Lines are compared without their line endings, so a missing final newline is not counted as a change.
- An empty text counts as zero lines, so every line of the other text shows as added or removed.
Example input:
{"mode": "text","old_text": "alpha\nbeta\ngamma\n","new_text": "alpha\nBETA\ngamma\ndelta\n","context_lines": 3}
Output (one dataset item):
{"mode": "text","identical": false,"old_lines": 3,"new_lines": 4,"added_lines": 2,"removed_lines": 1,"hunks": 1,"unified_diff": "--- old_text\n+++ new_text\n@@ -1,3 +1,4 @@\n alpha\n-beta\n+BETA\n gamma\n+delta\n"}
In the diff, lines starting with - were removed from the old text, lines starting with + were added in the new text, and lines starting with a space are unchanged.
Mode: json
- Both inputs must be valid JSON. NaN and Infinity are refused.
- Output fields:
identical,added_count,removed_count,changed_count, and the listsaddedandremoved(each item has apathand avalue) andchanged(each item has apath,oldandnew). - Paths start at
$. Keys that are not plain names are quoted, for example$["my key"]. 1,1.0,trueand"1"are different values, so a change between them is reported aschanged.context_linesis not used in this mode.
Example input:
{"mode": "json","old_text": "{\"a\": 1, \"gone\": true, \"c\": [1, 2]}","new_text": "{\"a\": 2, \"b\": false, \"c\": [1, 2, 3]}"}
Output (one dataset item):
{"mode": "json","identical": false,"added_count": 2,"removed_count": 1,"changed_count": 1,"added": [{ "path": "$.c[2]", "value": 3 },{ "path": "$.b", "value": false }],"removed": [{ "path": "$.gone", "value": true }],"changed": [{ "path": "$.a", "old": 1, "new": 2 }]}
Pricing
- $0.005 per successful run (UNCONFIRMED against the live Store) (event
conversion). One run compares one pair of texts or documents. - Failed runs (bad input, an unsupported mode, invalid JSON, a value over the size limit) are not charged.
- Apify's own platform usage for the run is separate from this price.
Limits
- Size: each input can be up to 1,000,000 bytes by default. Set
max_input_bytesto go up to 5,000,000 bytes. The limit applies to each input on its own. - Context lines: 0 to 10 in text mode.
- JSON nesting: documents nested too deeply to compare are refused with a message.
- JSON lists are compared position by position. Inserting one item at the start of a list reports every later item as changed, because each one now sits at a different position.
- Text mode works line by line. A block that moved shows as a removal in one place and an addition in another.
FAQ
Does it send my data anywhere? The comparison code makes no outside requests in its own code, reads no files and does no scraping. The result is saved to your run's storage on Apify, like any Apify actor's output.
Which diff format does text mode use? The standard unified diff format, produced by Python's difflib module.
Can I call it from code? Yes, through the Apify API or the Apify client for JavaScript or Python, like any Apify actor.
I found a bug or need a feature. Open an issue on this actor's Issues tab.
AI use
The code for this actor was written with help from AI coding tools. The actor does not call an AI model when it runs. Its output comes from Python's standard difflib and json modules.
Made by Brightwater Tools.