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
Build Securely on Azure with Proven Frameworks Icon
Build Securely on Azure with Proven Frameworks

Lay a foundation for success with Tested Reference Architectures developed by Fortinet’s experts. Learn more in this white paper.

Moving to the cloud brings new challenges. How can you manage a larger attack surface while ensuring great network performance? Turn to Fortinet’s Tested Reference Architectures, blueprints for designing and securing cloud environments built by cybersecurity experts. Learn more and explore use cases in this white paper.
Download Now
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