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
Go From AI Idea to AI App Fast Icon
Go From AI Idea to AI App Fast

One platform to build, fine-tune, and deploy ML models. No MLOps team required.

Access Gemini 3 and 200+ models. Build chatbots, agents, or custom models with built-in monitoring and scaling.
Try 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