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
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free 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

6 days ago