A modern, web-based text diff tool with a VS Code-inspired interface for comparing and analyzing differences between two text files.
- Side-by-side diff view with color-coded changes
- Line-level and character-level difference highlighting
- Intelligent diff algorithm using Longest Common Subsequence (LCS)
- Navigate between differences with keyboard shortcuts or UI buttons
- Minimap visualization for quick navigation through large files
- Real-time line counting and character statistics
- Ignore whitespace - Compare content without whitespace sensitivity
- Ignore case - Case-insensitive text comparison
- Toggle line numbers - Show/hide line numbers in the editor
- Load files from your local system (supports most text formats)
- Save modified files with custom filenames
- File size validation with warnings for large files (>10MB)
- Error handling for corrupted or invalid files
- Drag & drop support for easy file loading
- Progress indicator for large file comparisons
- Responsive design optimized for desktop and mobile
- Touch-friendly interface with proper touch target sizes (44px minimum)
- Accessibility features with ARIA labels and screen reader support
- Keyboard shortcuts for power users
- VS Code-inspired dark theme for comfortable viewing
- Automatic update checking on startup (configurable)
- Manual update check via Help menu or toolbar button
- Direct download with progress bar (taskbar + in-app overlay)
- Version comparison with release notes display
- Settings modal with auto-update toggle, version info, and readme link
- β Positional comparison - Text stays in place; only changed characters highlighted in red
- β Click to edit - Double-click on diff view to return to editing
- β Direct update downloads - Updates download directly with progress bar instead of opening browser
- β Settings modal - Auto-update toggle, readme link, version info
- β Undo button - For mouse-only users
- β Clear All confirmation - Popup to prevent accidental data loss
- β HTTPS redirect validation - Blocks non-HTTPS redirects in update checker and downloader
- β
URL whitelist - External link IPC only allows
https://URLs - β Memory leak fix - ipcRenderer listener cleanup prevents accumulation
- β Debounced window state saves - Reduces disk I/O
- β 1MB response limit - Prevents DoS via oversized API responses
TextCompare works on all modern browsers with ES6 support:
| Browser | Minimum Version |
|---|---|
| Chrome | 51+ |
| Firefox | 54+ |
| Safari | 10+ |
| Edge | 15+ |
Required Features:
- ES6 JavaScript (arrow functions, const/let, template literals)
- FileReader API
- CSS Flexbox
- CSS Custom Scrollbars (webkit)
| Shortcut | Action |
|---|---|
Ctrl+Enter |
Compare texts |
Ctrl+Up |
Previous difference |
Ctrl+Down |
Next difference |
Ctrl+S |
Save right file |
Ctrl+Shift+S |
Save left file |
Escape |
Close help modal / Exit compare mode |
Visit the live demo: https://jj-repository.github.io/TextCompare/
Download native desktop applications for your platform:
Linux:
- AppImage (portable, works on most distributions)
- .deb package (Debian/Ubuntu)
Windows:
- Installer (.exe)
- Portable version (no installation required)
Desktop builds are automatically generated via GitHub Actions on every release. Check the Releases page for downloads.
- Download
index.html - Open it in any modern web browser
- No installation or build process required!
- Load or paste text into both the left and right panels
- Click the "Compare" button or press
Ctrl+Enter - View highlighted differences:
- π’ Green - Added lines/text
- π΄ Red - Removed lines/text
- π‘ Yellow/Red underline - Modified characters
- Use Prev/Next buttons or keyboard shortcuts to navigate between differences
- Use the minimap on the right side for quick navigation
- Save your changes when done
- Single-file application - Zero dependencies, pure vanilla JavaScript
- Client-side processing - All comparisons happen in your browser (no server uploads)
- Efficient algorithms - LCS dynamic programming for optimal diff computation
- Modular code - IIFE pattern prevents global namespace pollution
- Optimized for files up to 10MB - Larger files will show a warning
- Async processing - UI remains responsive during comparisons
- Memory efficient - Blob URLs properly cleaned up after file operations
- No external dependencies - No CDN or third-party scripts
- Client-side only - Your files never leave your computer
- HTML escaping - Protection against XSS via proper text escaping
- Safe file handling - FileReader API with error handling
TextCompare supports all text-based file formats, including:
- Plain text (
.txt) - Markdown (
.md) - JSON (
.json) - XML/HTML (
.xml,.html) - Code files (
.js,.py,.java,.c,.cpp,.h,.css) - Config files (
.ini,.cfg,.yaml,.yml) - Logs (
.log) - CSV files (
.csv) - Any other text-based format
- File size: Recommended maximum of 10MB per file (browser may freeze on larger files)
- Binary files: Not supported (text files only)
- Character encoding: UTF-8 recommended (other encodings may display incorrectly)
- Line endings: Handles CRLF/LF automatically
- Algorithm complexity: O(mΓn) time, optimized space usage with Uint8Array for large files
TextCompare/
βββ index.html # Complete web application (HTML + CSS + JS)
βββ electron-main.js # Electron main process (window, menu, updates, download)
βββ preload.js # Context bridge for IPC
βββ package.json # Node.js dependencies and build config
βββ icon.png # Application icon (512x512 PNG)
βββ takodachi.webp # Mascot image for settings modal
βββ .github/
β βββ workflows/
β βββ deploy.yml # GitHub Pages deployment
β βββ build-executables.yml # Desktop app builds
βββ .gitignore # Git ignore rules
βββ README.md # This file
-
Install dependencies:
npm install
-
Run in development mode:
npm start
-
Build for your platform:
# Linux npm run build:linux # Windows npm run build:win # Both npm run build:all
-
Find built executables in
dist/folder
Note: You'll need to add an icon.png (512x512) for the application icon. See icon.png.txt for details.
- β Strict mode enabled
- β No console errors in production
- β Proper event cleanup
- β WCAG 2.1 accessibility compliant
- β Mobile-first responsive design
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
- β¨ Positional comparison: Text stays in place after compare β only different characters highlighted in red
- β¨ Click to edit: Double-click on diff view to go back to editing
- β¨ Direct update download: Updates download directly with progress bar instead of opening browser
- β¨ Settings modal: Auto-update toggle, readme link, version info
- β¨ Undo button: For mouse-only users
- β¨ Clear All confirmation: Popup to prevent accidental data loss
- π Security: HTTPS validation on all redirects (update checker & downloader)
- π Security: URL whitelist on external link IPC
- π Bug fix: Fixed ipcRenderer listener memory leak
- π§Ή Code quality: Debounced window state saves, dead code cleanup, optimized escapeHtml
- π Security: Download filename sanitization prevents path traversal via malicious release assets
- π Security: Download URL HTTPS validation before starting request
- π Security: Single-quote XSS escaping added to index.html escapeHtml
- β‘ Performance: LCS backtracking O(n) via push+reverse (was O(n^2) unshift)
- π Bug fix: Concurrent update check guard prevents overlapping downloads
- π Bug fix: Update flag properly cleared on all 12+ exit paths
- π‘οΈ Stability: 5-minute download timeout prevents hung downloads
- π‘οΈ Stability: Unhandled promise rejection handler prevents silent crashes
- π§Ή Code quality: Deduplicated update response reading logic (120 lines to 40)
- π§Ή CI: Build workflow only triggers on tags (was building on every push)
- β¨ Updates: Added automatic update checking on startup (configurable)
- β¨ Updates: Added "Check for Updates on Startup" toggle in Help menu
- β¨ Settings: Added settings persistence to user data directory
- π§Ή Code quality: Improved code organization
- π Security: Removed inline onclick handlers, use addEventListener for CSP compliance
- π Security: Added CSP comment explaining unsafe-inline requirement
- π Security: Added filename sanitization in save function
- π‘οΈ Reliability: Added isComparing flag to prevent concurrent comparisons
- π‘οΈ Reliability: Improved FileReader error handling with detailed messages
- π‘οΈ Reliability: Added bounds validation in LCS backtracking
- π§Ή Code quality: Validate dp matrix before accessing in backtrack function
- β‘ Performance: Optimized LCS algorithm with Uint8Array for large files
- β‘ Performance: Debounced scroll sync for smoother 60fps scrolling
- β‘ Performance: Array join for efficient HTML string building
- βΏ Accessibility: Added focus trap for help modal
- βΏ Accessibility: Added :focus-visible styles for keyboard navigation
- π Security: Added Content-Security-Policy meta tag
- π Security: Screen bounds validation prevents off-screen windows
- πΎ Desktop: Window state persistence (position, size, maximized)
- π Bug fix: Fixed minimap onclick handlers not working on left panel
- π§Ή Code quality: Cached 11 DOM element references
- π§Ή Code quality: Extracted magic numbers to named constants
- π§Ή Code quality: Fixed inconsistent indentation throughout
- β¨ Desktop apps: Added Electron-based builds for Linux and Windows
- β¨ GitHub Actions: Automated desktop executable builds on releases
- β¨ Added file size validation with 10MB warning
- β¨ Added comprehensive error handling for file operations
- β¨ Added loading spinner for large file comparisons
- β¨ Improved accessibility with full ARIA support
- β¨ Enhanced mobile/touch support with 44px touch targets
- β¨ Wrapped JavaScript in IIFE pattern for better encapsulation
- β¨ Added responsive design for screens < 768px
- π§Ή Removed unused CSS classes
- π Added comprehensive documentation
- π Fixed potential memory leaks with blob URL cleanup
- π¦ Added package.json and Electron configuration
- π€ Added automated build workflow for cross-platform executables
- π Initial release with core diff functionality
- π Side-by-side text comparison
- π¨ VS Code-inspired dark theme
- β¨οΈ Keyboard shortcuts
- πΊοΈ Minimap for navigation
- πΎ File load/save capabilities
Created with β€οΈ using vanilla JavaScript, no frameworks required.
Algorithm: Longest Common Subsequence (LCS) dynamic programming approach.
If you encounter any issues or have suggestions, please open an issue on GitHub.
Live Demo: https://jj-repository.github.io/TextCompare/