String Difference Checker
Compare two strings and see additions, deletions, and changes.
What is String Difference Checker?
A string diff tool takes two strings, aligns them character by character, and highlights every character that was inserted, deleted, or changed. Where a line-based diff reports “this line changed,” a string diff points at the exact characters that shifted. The implementation is a longest common subsequence (LCS) pass with each non-matching span rendered in place.
Developers, testers, and data engineers reach for a string diff when two short, near-identical inputs disagree. Typical inputs are two API keys, a generated hash against a fixture, a UUID that fails validation, or a snapshot test that broke by one character.
Why use String Diff?
- Pinpoint a single-character mismatch. When two tokens or hashes look identical and one is wrong, the diff exposes the offending character in red instead of forcing you to count positions.
- Debug snapshot test failures. Paste expected and actual output to see which whitespace, punctuation, or stray newline broke the assertion.
- Catch invisible Unicode drift. Smart quotes, non-breaking spaces, and the wrong dash often render identically but show up clearly in the diff.
- Stay private with secrets. The diff runs entirely in your browser, so API keys, tokens, and customer identifiers stay on your machine.
How to use String Diff
- Paste the first string into the Original textarea on the left.
- Paste the second string into the Modified textarea on the right.
- Read the Diff panel below for a row-by-row view of added (green), removed (red), and changed (amber) segments.
- Compare the prefix of each row (
+,−,~) to identify the change type. - Copy any highlighted segment into a bug report or a test assertion.
Character-level vs word-level diffs
A character-level diff treats every character as an independent unit and reports the smallest possible change. It suits short inputs where you need to know exactly which byte differs (an API key, a hash, a UUID, a hostname).
A word-level diff treats each whitespace-separated token as the unit and suits short prose. A single-letter typo inside a sentence is easier to scan as one highlighted word than as a one-character delta surrounded by unchanged context.
| Mode | Unit | Best for |
|---|---|---|
| Character-level | One Unicode code unit | Hashes, tokens, IDs, hostnames, URLs |
| Word-level | One whitespace token | Short prose, log messages, error strings |
| Line-level | One line | Multi-line strings with structure |
Both modes use the same LCS core; only the tokenization differs.
Worked example
Two presigned URLs that differ in their expiry parameter:
- https://cdn.example.com/img/42.png?expires=1735689600&sig=a1b2c3
+ https://cdn.example.com/img/42.png?expires=1735693200&sig=a1b2c3A character-level diff renders the URLs almost entirely in gray, with 9600 shown in red and 3200 in green inside the expires value. The signature stays untouched, so the breakage was an expiry refresh, not a signing key mismatch.
A second example, a fixture mismatch in a snapshot test:
- Welcome back, Alex - your last login was Friday.
+ Welcome back, Alex – your last login was Friday.The two lines look identical to most readers. The diff highlights the hyphen-minus (-) in red and the en dash (–) in green, naming the exact character that drifted.
Common use cases
- Backend developers debugging signature mismatches. Diff the canonical string your code signs against the one the server received to find the encoding bug.
- QA engineers triaging snapshot tests. Paste expected and received snapshots to isolate the one character, often invisible whitespace, that broke the assertion.
- Support engineers checking customer-reported tokens. Compare the API key the customer pasted with the one in your dashboard to catch transcription errors.
- Localization reviewers spotting smart-quote drift. Diff translated strings against the source to catch typographic substitutions that broke a parser.
Frequently asked questions
Is the string diff case-sensitive?
Yes. The diff treats A and a as different characters, so a casing change is reported as a real change. There is no case-insensitive mode, because most strings a developer needs to diff (tokens, hashes, hostnames, IDs) are case-sensitive.
Does it ignore whitespace?
No. Spaces, tabs, and newlines are first-class characters, so a trailing space or stray newline shows up as an added or removed segment. Invisible whitespace is the most common cause of “the strings look the same but the test still fails.”
Can I compare two files?
The tool reads from two textareas, not file uploads. For long files where you care about line-level changes, use Text Compare; for structured payloads, use JSON Compare or XML Compare.
Are my strings uploaded anywhere?
No. The string diff runs entirely in the browser. Both inputs stay in memory in your tab and are never sent to a server, written to disk, or logged. Closing the tab clears them, which makes the tool safe for API keys and customer data.
What is the maximum input size?
Character-level diffs are most useful on short strings, up to a few thousand characters per side. Above that, every character becomes a DOM node and the tab can slow down. For long inputs, switch to Text Compare.
Why are two strings that look identical reported as different?
The most common cause is an invisible Unicode character. Non-breaking spaces (U+00A0), zero-width joiners (U+200D), byte-order marks (U+FEFF), and smart quotes all render like ASCII counterparts in most fonts. A one-segment difference at the start of the string is almost always a BOM or a non-breaking space.
Does the diff handle multi-byte characters?
Yes. The tokenizer works on JavaScript string units, so non-Latin scripts and emoji are diffed at the code-point level rather than the byte level.
Related tools
- Code Compare - Side-by-side diff of two code snippets with monospaced rendering.
- Text Compare - Line and word diff for two blocks of plain text.
- XML Compare - Diff two XML documents line by line.
- Regex Tester - Test a regular expression against sample input and inspect every match.
Related tools
ShotMark captures what you do here, in one click.
The traces, payloads, and tests you run by hand? ShotMark grabs the whole bug and hands it to your AI agent.