# Text Diff Checker (`web.harvester/text-diff-checker`) Actor

Compare two texts and highlight differences. Shows additions, deletions, and changes. Multiple output formats: unified, side-by-side, HTML.

- **URL**: https://apify.com/web.harvester/text-diff-checker.md
- **Developed by:** [Web Harvester](https://apify.com/web.harvester) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 9 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#rental-actors

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Text Diff Checker

> 📝 Compare two texts and highlight differences. Shows additions, deletions, and changes with multiple output formats.

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-blue)](https://apify.com)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

### 🎯 What This Actor Does

Compare texts and find differences:

- **Unified Diff** - Git-style diff output
- **Side by Side** - Compare lines directly
- **HTML Output** - Visual diff with colors
- **Statistics** - Additions, deletions, similarity %
- **Options** - Ignore case, whitespace

### 🚀 Use Cases

| Use Case | Description |
|----------|-------------|
| **Code Review** | Compare code versions |
| **Document Versioning** | Track document changes |
| **Content Audit** | Find text modifications |
| **Plagiarism Check** | Compare similarity |
| **Translation QA** | Compare translations |
| **Data Validation** | Verify data changes |

### 📥 Input Examples

#### Basic Comparison

```json
{
    "text1": "The quick brown fox jumps over the lazy dog.",
    "text2": "The quick brown cat jumps over the lazy dog!",
    "outputFormat": "unified"
}
```

#### HTML Output

```json
{
    "text1": "Hello World\nThis is line 2",
    "text2": "Hello Universe\nThis is line 2\nNew line 3",
    "outputFormat": "html"
}
```

#### Ignore Case/Whitespace

```json
{
    "text1": "Hello   World",
    "text2": "hello world",
    "ignoreCase": true,
    "ignoreWhitespace": true
}
```

### ⚙️ Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `text1` | string | - | Original/old text |
| `text2` | string | - | Modified/new text |
| `outputFormat` | string | `unified` | unified, side\_by\_side, html, json |
| `contextLines` | integer | `3` | Lines around changes |
| `ignoreCase` | boolean | `false` | Ignore uppercase/lowercase |
| `ignoreWhitespace` | boolean | `false` | Ignore space differences |

### 📤 Output

```json
{
    "format": "unified",
    "additions": 1,
    "deletions": 1,
    "changes": 0,
    "similarity": 85.71,
    "totalLines1": 3,
    "totalLines2": 4,
    "diff": "--- original\n+++ modified\n@@ -1,3 +1,4 @@..."
}
```

### 📊 Output Formats

| Format | Best For | Output |
|--------|----------|--------|
| `unified` | Developers | Git-style diff text |
| `side_by_side` | Visual comparison | Array of line pairs |
| `html` | Reports | Styled HTML page |
| `json` | Automation | Word-level diff array |

### 💰 Cost Estimation

| Text Size | Approx. Time | Compute Units |
|-----------|--------------|---------------|
| 1 KB | ~1 second | ~0.001 |
| 100 KB | ~2 seconds | ~0.003 |
| 1 MB | ~5 seconds | ~0.01 |

### 🔧 Technical Details

- **Language:** Python 3.12
- **Library:** difflib (built-in)
- **Memory:** 128MB-256MB
- **Algorithm:** SequenceMatcher (Ratcliff/Obershelp)

### 📄 License

MIT License - see [LICENSE](LICENSE) for details.

***

### 🏪 Apify Store Listing

<details>
<summary>Click to copy store details</summary>

**Actor name:**

```
Text Diff Checker
```

**Description:** *(298/300 chars)*

```
Compare two texts and highlight differences. Shows additions, deletions, and changes. Multiple output formats: unified diff, side-by-side, HTML. Calculate similarity percentage. Options to ignore case and whitespace. Perfect for code review, document versioning, and content auditing.
```

**SEO Actor name:**

```
Text Diff Checker - Compare & Find Changes
```

**SEO Description:** *(197/200 chars)*

```
Compare two texts, find differences. Unified diff, side-by-side, HTML output. Additions, deletions, similarity %. Ignore case/whitespace. For code review, versioning.
```

**Icon:** Use `assets/icon.svg` in this folder

</details>

***

**Keywords:** text diff, compare texts, diff checker, text comparison, unified diff, side by side, similarity, document compare

# Actor input Schema

## `text1` (type: `string`):

The original/old text to compare

## `text2` (type: `string`):

The modified/new text to compare

## `outputFormat` (type: `string`):

How to display the differences

## `contextLines` (type: `integer`):

Number of unchanged lines to show around changes

## `ignoreCase` (type: `boolean`):

Treat uppercase and lowercase as equal

## `ignoreWhitespace` (type: `boolean`):

Ignore differences in spaces and tabs

## Actor input object example

```json
{
  "text1": "The quick brown fox jumps over the lazy dog.",
  "text2": "The quick brown cat jumps over the lazy dog!",
  "outputFormat": "unified",
  "contextLines": 3,
  "ignoreCase": false,
  "ignoreWhitespace": false
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "text1": "The quick brown fox jumps over the lazy dog.",
    "text2": "The quick brown cat jumps over the lazy dog!"
};

// Run the Actor and wait for it to finish
const run = await client.actor("web.harvester/text-diff-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "text1": "The quick brown fox jumps over the lazy dog.",
    "text2": "The quick brown cat jumps over the lazy dog!",
}

# Run the Actor and wait for it to finish
run = client.actor("web.harvester/text-diff-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "text1": "The quick brown fox jumps over the lazy dog.",
  "text2": "The quick brown cat jumps over the lazy dog!"
}' |
apify call web.harvester/text-diff-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,web.harvester/text-diff-checker"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/1vuFektGjPhhZYkLL/builds/KMm1NimdHaTuNtfrQ/openapi.json
