---
title: Differentiate Text API
slug: compare-text-or-code-snippets
url: https://apyhub.com/apyhub/service/compare-text-or-code-snippets
provider: ApyHub
categories: [Developer Tools]
tags: [text-diff, code-diff, snippet-comparison, change-tracking, diff-analysis]
auth: api_key
---

# Differentiate Text API

Compare two text or code snippets and get ordered diff segments plus addition, deletion, and unchanged counts for review and change tracking.

## Endpoints

| Method | Path | Description | Atoms |
| --- | --- | --- | --- |
| POST | `` | What it does Compares two text or code snippets and returns a diff breakdown plus summary statistic… | 40 |

## About

## What it does
Text Diff Comparator compares two text or code snippets and returns an ordered diff, plus simple change counts. Send `text1` and `text2`, and optionally set `mode` to `char`, `word`, or `line` depending on whether you're checking typos, prose, or multi-line code and config files.

Use `word` mode for sentences and paragraphs, `line` mode for source files, JSON, YAML, and other structured text, and `char` mode when small edits matter. The response includes the normalised `mode` used for comparison, a `diffs` array with `equal`, `insert`, and `delete` segments, and `stats` with `additions`, `deletions`, and `unchanged` counts.

This is useful for review workflows, content editors, code inspection tools, and any integration that needs to explain what changed between two versions without doing its own diffing. Because the diff segments are returned in order, you can render side-by-side comparisons, highlight edits inline, or compute summary metrics from the same response.

If you need a straightforward way to compare revisions and inspect the exact segments that differ, Text Diff Comparator gives you the result in a compact, machine-readable format.

## Usage

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/apyhub/service/compare-text-or-code-snippets
