Skip to content

teimurjan/blazediff

Repository files navigation

BlazeDiff

License: MIT NPM Version Benchmark Object Benchmark Ask DeepWiki

BlazeDiff — a high-performance diff ecosystem for JavaScript applications. Originally built as a pixel-perfect image comparison library that's 1.5x faster than pixelmatch, BlazeDiff has evolved into a comprehensive suite of blazing-fast diff tools including image comparison, object diffing, web components, and React components for visualizing differences. Designed for visual testing, CI/CD pipelines, data validation, and any application requiring fast, accurate comparison operations.

Features

BlazeDiff provides a complete ecosystem of high-performance diff tools:

  • Image Diff: Pixel-perfect image comparison with 1.5x performance improvement over pixelmatch
  • Object Diff: Lightning-fast structural object comparison with detailed change tracking
  • Web Components: Framework-agnostic components for displaying diffs in web applications
  • React Components: Purpose-built React components for seamless diff visualization

Image Diff

BlazeDiff's image comparison is 1.5x faster than pixelmatch while maintaining identical accuracy and output quality. The performance improvement comes from:

  • Block-based algorithm: Dynamic-sized blocks with processing only for changed areas
  • Early exit optimization: Immediate return for identical images (Native C++ in Node)
  • 32-bit integer comparisons: CPU vectorization for faster pixel matching
  • Multiple format support: PNG, JPEG, and WebP when using Sharp transformer
Expected Actual Diff
Expected Actual Diff

100% API and Result Compatible: BlazeDiff is fully compatible with pixelmatch's API and produces identical results when using the YIQ color space flag.

Object Diff

BlazeDiff's object comparison provides blazing-fast structural diffing with comprehensive change detection:

  • High-performance algorithm: Optimized for speed with intelligent key lookup strategies
  • Detailed change tracking: Precise path tracking for nested object modifications
  • Comprehensive type support: Handles primitives, objects, arrays, dates, regex, and circular references
  • Memory efficient: Minimal overhead with consistent object shapes for V8 optimization
Original Modified Changes
{
  "name": "John",
  "age": 30,
  "city": "NYC",
  "skills": ["JS", "TS"]
}
{
  "name": "John",
  "age": 31,
  "city": "SF",
  "skills": ["JS", "TS", "Go"],
  "active": true
}
[
  {
    "type": 2,
    "path": ["age"],
    "value": 31,
    "oldValue": 30
  },
  {
    "type": 2,
    "path": ["city"],
    "value": "SF",
    "oldValue": "NYC"
  },
  {
    "type": 0,
    "path": ["skills", 2],
    "value": "Go",
    "oldValue": undefined
  },
  {
    "type": 0,
    "path": ["active"],
    "value": true,
    "oldValue": undefined
  }
]

Difference Types:

  • 0 (CREATE) - Property or array element was added
  • 1 (REMOVE) - Property or array element was deleted
  • 2 (CHANGE) - Property or array element value was modified

Use Cases

BlazeDiff is available in multiple packages to suit different use cases:

Core Libraries

  • @blazediff/core - Core JavaScript library for pixel-perfect image comparison
  • @blazediff/object - High-performance object diffing with detailed change tracking

Command Line Tools

  • @blazediff/bin - CLI for image comparison with multiple format support

UI Components

  • @blazediff/react - React components for displaying diffs in your applications
  • @blazediff/ui - Framework-agnostic web components for diff visualization

Benchmarks

BlazeDiff delivers significant performance improvements across all components:

  • Image Diff: ~50% faster than pixelmatch (up to 88% on identical images)
  • Object Diff: ~30% faster than microdiff (up to 96% on identical arrays)
  • CLI Tools: ~60% faster end-to-end performance with multi-format support

View Detailed Benchmarks - Complete performance data, test methodology, and hardware specifications.

Contributing

Contributions are welcome! Please see the Contributing Guide for details.

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Image diffing built on the excellent pixelmatch algorithm

Built for high-performance difference detection across images and data structures