How to compare two texts (diff)
Short answer
A diff compares two pieces of text and highlights what was added, removed, or unchanged. It is the fastest way to see exactly how one version differs from another, whether for code, documents, or AI prompts.
What a diff shows
Instead of reading both versions and hunting for changes, a diff aligns them and marks the differences: additions, removals, and the parts that stayed the same. You see the change at a glance.
- Added text, usually shown in one color
- Removed text, shown in another
- Unchanged text, shown plainly for context
Line vs word diffs
A line diff compares whole lines, which suits code and structured text. A word or character diff highlights smaller edits within a line, which is better for prose and prompts where only a few words changed.
When it helps
- Iterating on an AI prompt and checking exactly what you changed
- Reviewing edits to a document or message
- Spotting an accidental change between two copies of text