# Codeharbor Diff > Compare two texts line by line and get a unified diff with added and removed lines. Paste an original and a changed version of a file to see which lines were added, removed or kept, grouped into hunks with context, as a unified diff like git diff or diff -u — the same comparison Codeharbor uses for snapshots and commits. Part of usefulweb.site (https://usefulweb.site/). Part of [Codeharbor](https://codeharbor.usefulweb.site/) (ownerApp: codeharbor). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://codeharbordiff.usefulweb.site/ (interactive tool at https://codeharbordiff.usefulweb.site/tool) - JSON API: POST https://codeharbordiff.usefulweb.site/api/v1/calculate with a JSON object of inputs (schema: https://codeharbordiff.usefulweb.site/api/v1/tool) - OpenAPI: https://codeharbordiff.usefulweb.site/openapi.json - MCP (Streamable HTTP): https://codeharbordiff.usefulweb.site/mcp - tool `codeharbor_diff` ## Inputs - original (textarea): Original - changed (textarea): Changed - originalName (text): Name of the original (optional) - changedName (text): Name of the changed version (optional) - context (number): Context lines around changes - ignoreWhitespace (boolean): Ignore differences in spaces and indentation ## Method - Both texts are split into lines (CRLF is treated as LF). Lines common to the start and end are set aside, then Myers’ O(ND) algorithm finds a shortest edit script between the rest: the fewest added plus removed lines. - Changes are grouped into hunks with the chosen number of unchanged context lines; hunks closer than twice the context are joined. The unified format shows “@@ -start,count +start,count @@” headers and lines starting with “-”, “+” or a space. - Similarity = 2 × unchanged lines ÷ (lines of both texts). With “ignore whitespace”, runs of spaces become one space and lines are trimmed before comparing.