Text diff checker
Paste two strings, two versions of a text or some code to compare them and see exactly what changed.
3 lines added, 2 removed.
| 1 | − | The quick brown fox | |
| 1 | + | The quick red fox | |
| 2 | 2 | jumps over the lazy dog. | |
| 3 | − | It was a sunny day. | |
| 3 | + | It was a sunny day, | |
| 4 | + | and the dog slept on. | |
| 4 | 5 | The end. |
How it works
Reading a diff
A diff lists what you would have to do to turn the original into the changed version. Lines marked + were added, lines marked − were removed, and an edited line shows up as one removed and one added line. The two number columns show where a line sits in the original and in the changed text.
Comparing two strings
The checker works just as well on two short strings as on whole files: an API key against the one in your config, two file paths, a header value from two environments, or an expected and actual value from a failing test. Paste one into each box and pick Words. In Lines mode a one-line string that differs shows up as one removed and one added line, which tells you that something changed but not where.
If the result says No differences with both ignore options off, the strings are identical, with one exception: Windows (CRLF) and Unix (LF) line endings count as the same. To prove two values are byte for byte equal, compare their SHA-256 in the hash generator, where line endings and trailing spaces count.
Strings that look the same but aren’t
When two strings look identical but don’t match, the difference is almost always a character you can’t see:
- A trailing space or tab. The line is marked as changed; turn on Ignore whitespace to confirm that is all it is.
- A non-breaking space (U+00A0), common in text copied from web pages and Word. In Words mode only the gap between two words is highlighted, and the summary says that only whitespace changed.
- A zero-width space (U+200B). It isn’t whitespace to the comparison, so the word it sits in shows as changed though it looks unchanged.
- Lookalike characters: curly quotes instead of straight ones, an en dash instead of a hyphen, or a Cyrillic “а” in a Latin word.
- Two ways to write an accent. “é” can be stored as one character or as “e” followed by a combining accent. Both display the same, but they are different strings.
Comparing strings in code
The same traps apply when you compare strings in a program. Normalize Unicode before an exact comparison, and decide on purpose whether case and accents matter:
// JavaScript
a === b // exact
a.normalize('NFC') === b.normalize('NFC') // same text, however accents are stored
a.localeCompare(b, 'en', { sensitivity: 'base' }) === 0 // ignores case and accents
# Python
a == b
unicodedata.normalize('NFC', a) == unicodedata.normalize('NFC', b)
a.casefold() == b.casefold() # ignores caseTo compare against a pattern rather than a fixed string, use the regex tester.
Good to know
- Moving a block of lines shows as removed in one place and added in another; a diff doesn’t track moves.
- Invisible differences, such as trailing spaces or tabs instead of spaces, can make lines differ. Ignore whitespace hides changes in spacing. Windows and Unix line endings are treated the same.
- For JSON, format both versions with the JSON formatter first, so formatting doesn’t hide the real changes.
More tools
More on the bench
- JSON formatter and validatorPretty-print, minify and validate JSON, with the exact line of any error.
- Base64 encoder and decoderEncode text to Base64 and back, including URL-safe Base64 and emoji.
- URL encoder and decoderPercent-encode and decode URLs and query values, and break a URL into parts.
- Regex testerTest JavaScript regular expressions live, with groups, replace and common patterns.
- CSV to JSON and JSON to CSVConvert CSV to JSON and JSON to CSV, with delimiter detection.
- UUID (GUID) generatorGenerate random v4 or time-ordered v7 UUIDs, one or up to 1,000 at a time.
- JWT decoderRead the header and claims of a JSON Web Token, with expiry dates in plain English.
- MD5 and SHA hash generatorMD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text, with a match check.
- Unix timestamp (epoch) converterEpoch seconds or milliseconds to a readable date and back in any time zone, ISO 8601 too.
- Lorem Ipsum generatorPlaceholder paragraphs, sentences or words, plain or as HTML.
Frequently asked questions
How do I compare two strings online?
Paste one string into Original and the other into Changed. For short strings on a single line, choose Words, so you see the exact word that differs instead of one removed and one added line. If the result says No differences, the two strings are the same, apart from Windows versus Unix line endings.
Why are two strings that look identical reported as different?
Because they contain different characters that look alike: a trailing space, a non-breaking space instead of a normal one, a zero-width space, curly instead of straight quotes, or an accented letter stored as a letter plus a separate accent. Compare in Words mode to find the spot, then retype or normalize it.
How does the comparison work?
It uses the Myers diff algorithm, the same one behind git diff: it finds the smallest set of lines (or words) to remove and add to turn the original into the changed text. Unchanged parts are shown in between for context.
When should I compare words instead of lines?
Lines suit code, configuration and lists, where each line stands on its own. Words suit prose, where one edited word would otherwise mark a whole paragraph as changed.
What do the ignore options do?
Ignore case treats "Fox" and "fox" as the same. Ignore whitespace treats lines as equal when they only differ in spaces, tabs or indentation, which helps after re-indenting code.
Is my text uploaded?
No. Both texts are compared in your browser and never leave your device, so it is safe for code and private documents.