What Is a Diff Viewer?
A diff viewer compares two inputs and highlights added, removed, or modified lines. In Text mode, content is compared exactly as entered. JSON and YAML modes first parse each document, recursively sort object keys, and format both sides consistently so property order and formatting noise do not hide meaningful data changes. Side-by-side and unified diff views are generated entirely in your browser.
How to Use the Diff Viewer
- 1Choose Text, JSON, or YAML from the comparison mode selector.
- 2Paste the original content into the 'Original' textarea on the left.
- 3Paste the modified text into the 'Modified' textarea on the right.
- 4For JSON or YAML, fix any explicitly reported parse errors; valid documents are canonicalized with recursively sorted keys.
- 5View the color-coded diff below: green for additions and red for deletions.
- 6Use the 'Swap' button to reverse the comparison direction.
- 7Switch between 'Side by Side' and 'Unified' tabs to change the diff format.
- 8Copy the unified diff output using the copy button for use in patches or documentation.
Common Use Cases
Code Review
Compare original and modified source code to quickly identify what changed, making it easier to review pull requests or patches.
Configuration File Changes
Compare JSON or YAML by data structure rather than key order and formatting, or use Text mode for .env and other configuration formats.
Document Revision Tracking
Compare drafts of documents, contracts, or articles to see exactly which sentences or paragraphs were edited.
Merge Conflict Resolution
Visualize conflicting changes from different branches to understand what each side modified before resolving the conflict.
Frequently asked questions
What diff formats are available?
Text, JSON, and YAML input modes are available. Results can be viewed Side by Side with color coding or as a standard Unified diff used by patches and version control systems.
Can I compare binary files or images?
No, this tool is designed for plain text comparison. For binary files or images, use specialized diff tools in your IDE or version control system.
Is my text sent to a server?
No. The comparison is performed entirely in your browser using the 'diff' JavaScript library. Your content never leaves your device.
How does the unified diff output work?
The unified diff format shows context lines (prefixed with a space), additions (prefixed with +), and deletions (prefixed with -), along with line range headers. This format is compatible with tools like git apply and the patch command.