Diff
Standard · 1 creditCompare two texts and get the differences as a unified diff or a structured list of changes.
POST /api/diff
Section titled “POST /api/diff”Parameters
Section titled “Parameters”| Field | Type | Required | Default | Description |
|---|---|---|---|---|
original | string | Yes | — | Original text |
modified | string | Yes | — | Modified text |
format | string | No | unified | Output format: unified, changes |
context_lines | integer | No | 3 | Lines of surrounding context in unified format (0–20) |
Response fields
Section titled “Response fields”| Field | Type | Description |
|---|---|---|
diff | string | Unified diff string (when format is unified) |
stats.additions | integer | Number of added lines |
stats.deletions | integer | Number of deleted lines |
hunks | array | Detailed hunk info — each has original_start, original_count, modified_start, modified_count, changes |
changes | array | Flat list when format is changes — each has type (insert, delete, equal) and text |
hunksappears inunifiedformat responses. Top-levelchangesappears inchangesformat responses.
Example: Unified diff
Section titled “Example: Unified diff”curl -X POST https://morso.dev/api/diff \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"original": "hello world\nfoo bar", "modified": "hello morso\nfoo bar\nnew line"}'{ "diff": "--- original\n+++ modified\n@@ -1,2 +1,3 @@\n-hello world\n+hello morso\n foo bar\n+new line", "stats": { "additions": 2, "deletions": 1 }, "hunks": [ { "original_start": 1, "original_count": 2, "modified_start": 1, "modified_count": 3, "changes": [ { "type": "delete", "text": "hello world" }, { "type": "insert", "text": "hello morso" }, { "type": "equal", "text": "foo bar" }, { "type": "insert", "text": "new line" } ] } ]}Example: Structured changes
Section titled “Example: Structured changes”curl -X POST https://morso.dev/api/diff \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"original": "hello world", "modified": "hello morso", "format": "changes"}'{ "stats": { "additions": 1, "deletions": 1 }, "changes": [ { "type": "delete", "text": "hello world" }, { "type": "insert", "text": "hello morso" } ]}