diff is a standalone PHP library for computing and rendering textual differences, widely used to display “expected vs actual” output in testing tools. It supports line-based and character/word-granular comparisons so you can get both coarse and fine-grained views of changes. Output builders can produce formats like unified or context diffs, or more human-friendly renderings suitable for terminals and HTML reports. Internally, the library splits input into hunks and manages edge cases such as whitespace-only changes and end-of-line variations. Its abstractions make it straightforward to plug custom output styles or colorizers without reimplementing diff logic. Because it’s the diff engine under PHPUnit, it has been exercised across countless projects and edge cases.

Features

  • Compute line-level and granular word or character diffs
  • Unified and context diff renderers with configurable output builders
  • Hunk management that groups related edits for easier reading
  • Sensible handling of whitespace and newline edge cases
  • Extensible architecture for custom colorization and HTML renderers
  • Proven reliability through long-term use in PHPUnit and other tools

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

BSD License

Follow sebastian/diff

sebastian/diff Web Site

Other Useful Business Software
Try Google Cloud Risk-Free With $300 in Credit Icon
Try Google Cloud Risk-Free With $300 in Credit

No hidden charges. No surprise bills. Cancel anytime.

Use your credit across every product. Compute, storage, AI, analytics. When it runs out, 20+ products stay free. You only pay when you choose to.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of sebastian/diff!

Additional Project Details

Programming Language

PHP

Related Categories

PHP Libraries

Registered

2025-10-22