String Compare
Compare two strings online — check if strings are identical or find character-by-character differences. Useful for debugging API responses, config values, and text encoding issues.
Why Use a Text Comparison Tool?
- Character-level comparison reveals invisible differences — trailing spaces, Unicode look-alike characters, and different quote types (curly vs straight) cause string mismatch
- Code review efficiency: Review configuration changes, script modifications, or code patches without a git repository — compare any two text sources directly.
- Document version tracking: Identify every change between contract drafts, policy documents, or proposal revisions without manually reading both versions.
- Data validation: Compare expected vs actual output from scripts, APIs, or data processing pipelines to identify discrepancies.
- Plagiarism detection: Compare submitted documents against original sources to identify modified but substantially copied text.
How to Compare Texts
- Paste original text: In the left panel, paste the original version — the baseline or earlier version of your text.
- Paste modified text: In the right panel, paste the updated version — the current or changed version.
- Choose diff mode: Line-level diff for code and structured data; word-level diff for prose and human-readable documents; character-level for precise string debugging.
- Review highlighted differences: Green highlights = text added in the modified version; red highlights = text removed from the original; unchanged text shown for context.
- Export if needed: Copy the diff output or download as HTML for documentation, code review comments, or sharing with colleagues.
Real-World Use Case
A developer debugs why two API responses that look identical produce different hashes — a string comparison reveals a trailing newline character in one response The visual diff makes changes instantly obvious — review that takes 20 minutes of careful manual reading completes in 30 seconds with highlighted diff output. The color-coded comparison also catches subtle changes (a single character difference, a changed number) that manual reading often misses.
Best Practices
- Paste strings with surrounding quotes to detect if quote characters differ — a Unicode left double quotation mark (U+201C) looks identical to an ASCII double quote (U+0022) but fails string equality
- Ignore whitespace for code comparison: Enable "ignore whitespace" option when comparing code reformatted with different indentation — shows only meaningful logic changes.
- Use context lines for code review: Show 3–5 context lines around each change to understand what code surrounds modifications.
- Compare normalized data: For JSON or CSV comparison, format both versions consistently (sort keys, consistent quoting) before comparing to avoid false positives from formatting differences.
- Break large documents into sections: Comparing 10,000+ line documents may be slow — split into logical sections (chapters, modules) for faster, more focused comparison.
Performance & Limits
- Maximum text size: Up to 500,000 characters per input panel (approximately 5,000–10,000 lines of code).
- Diff algorithm: Myers diff algorithm — the same algorithm used by git for accurate, minimal change detection.
- Processing speed: Most comparisons complete instantly; very large documents (100,000+ characters) may take 1–3 seconds.
- Output formats: Side-by-side view, unified diff view (like git diff output), and inline diff (changes highlighted within the text).
- Case sensitivity: Toggle case-sensitive vs case-insensitive comparison depending on whether capitalization differences matter for your use case.
Common Mistakes to Avoid
- Line ending mismatches causing spurious diffs: Windows (CRLF) vs Unix (LF) line endings cause every line to appear changed — enable "normalize line endings" or paste plain text without encoding differences.
- Ignoring small differences in numbers: "1.0" vs "1" or "true" vs "True" may appear as trivial differences but break API calls or configuration parsing — treat each as a meaningful change.
- Comparing formatted vs unformatted code: An auto-formatted code file vs an unformatted version shows hundreds of whitespace changes — compare only after formatting both consistently.
- Not checking character encoding: UTF-8 vs Latin-1 encoding for special characters can cause invisible character differences that appear as text changes.
Privacy & Security
- Client-side comparison: All text comparison processing runs in your browser — text content is never transmitted to external servers.
- Source code safe: Compare proprietary code, confidential configuration files, or sensitive documents without risk of content exposure.
- No logging: Text content you paste for comparison is not logged, stored, or accessible to anyone else.
- Session-only access: Pasted text exists in browser memory only and is cleared when you navigate away or close the tab.
Frequently Asked Questions
What diff algorithm does the tool use?
This tool uses the Myers diff algorithm — the same algorithm used by git, GitHub, and most version control systems for computing minimal edit differences. The Myers algorithm finds the shortest edit script (minimum number of insertions and deletions) to transform one text into another. It's efficient for typical code and document comparison, running in O(ND) time where N is the total text length and D is the number of differences. For very long texts with many differences, a linear-time variant (Patience diff or Histogram diff, as used by some git configurations) may be more appropriate. For most real-world comparison tasks — document versions, configuration files, code files — the Myers algorithm produces clean, minimal diffs that accurately reflect intentional changes.
How do I compare two Word documents for differences?
To compare Word documents using this tool: open both documents in Microsoft Word; select all text in document 1 (Ctrl+A), copy (Ctrl+C), paste into the left panel; repeat for document 2 in the right panel. This compares the plain text content — formatting changes (font, bold, color) won't show, but content changes will. For formatting-aware comparison: Word itself has a built-in "Compare Documents" feature (Review → Compare → Compare) that shows formatting and content differences with tracked changes markup. Google Docs has "Version history" for documents stored there. The browser-based text diff tool is best for plain text content comparison; use Word's Compare feature when document formatting differences also matter.
Can I use this to compare JSON or XML files?
Yes — JSON and XML comparison works, with one important caveat: the diff compares text character-by-character, so semantically identical JSON with different formatting (spaces, key ordering) will show many "differences" that aren't actual data changes. Best practice for JSON comparison: format both JSON objects consistently first using a JSON formatter (consistent indentation, consistent key sorting) before pasting — this eliminates formatting noise from the diff. For semantic JSON comparison (where key order and whitespace are irrelevant), specialized JSON diff tools that parse and compare the data structure produce cleaner results. The text diff tool is most useful for comparing JSON that should be identical and finding small discrepancies, not for comparing structurally equivalent but differently-formatted JSON.
How do I find where two strings differ when they look identical?
When two strings appear visually identical but don't match, common culprits are: invisible Unicode characters (zero-width space U+200B, left-to-right mark U+200F, BOM U+FEFF) — use character-level diff to detect; look-alike characters (Latin 'a' vs Cyrillic 'а', or different Unicode dash types — en dash, em dash, minus sign); different whitespace characters (regular space U+0020 vs non-breaking space U+00A0 vs en space U+2002); trailing or leading whitespace; carriage return (CR) characters appearing as invisible characters in line endings. Character-level comparison in the diff tool shows every character's position — invisible characters appear as highlighted empty spaces in the diff output, making them detectable.