diff2html

Generate pretty, GitHub-style HTML diffs from git diff or unified diff output

Library
npm
v3.4.56
3,405stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity12
Maintenance44
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture74
Code Quality72
Innovation65
Learning Curve78

diff2html turns raw git diff or unified diff text into readable, GitHub-style HTML — either as line-by-line or side-by-side views, with syntax highlighting, a summarized file list, and line-similarity matching to visually pair changed lines. It ships as both a pure parser/renderer library (diff2html) for Node.js and the browser, and an optional UI wrapper (Diff2HtmlUI) that adds synchronized scrolling and highlight.js integration.

It’s commonly embedded in code review tools, changelog generators, git hosting UIs, and any application that needs to render a diff for humans rather than just showing raw patch text.

What You Get

  • A parse() function that turns raw diff text into a typed DiffFile[] structure (files, blocks, added/removed/unchanged lines)
  • An html() function that renders that structure (or raw diff text directly) into line-by-line or side-by-side HTML output
  • A Diff2HtmlUI wrapper that adds highlight.js syntax highlighting, a table of contents/file list, and synchronized side-by-side scrolling for direct DOM insertion
  • Prebuilt browser bundles (CDN/jsDelivr-ready) plus CommonJS and ESM builds for Node.js and bundler consumption
  • Line-similarity matching that visually pairs a removed line with the replaced line it most closely resembles

Common Use Cases

  • Embedding readable diff views in code review tools, PR dashboards, or internal git hosting UIs
  • Rendering changelogs or commit-diff previews on documentation/marketing sites
  • Building CLI or CI tooling that needs to convert git diff output into shareable HTML reports

Under The Hood

Architecture: src/diff-parser.ts is the core parsing engine — it walks unified-diff text line by line, tracking file headers, hunk offsets, and line-type prefixes (+/-/context) to build a typed DiffFile[] tree (src/types.ts). src/diff2html.ts is the thin public entry point: parse() exposes the parser directly, and html() composes it with one of two renderer classes — LineByLineRenderer or SideBySideRenderer (each ~300 lines) — plus an optional FileListRenderer for the summary header. Rendering itself is template-based via HoganJsUtils (a wrapper around @profoundlogic/hogan, a Mustache-family engine), with rematch.ts implementing the line-similarity algorithm that pairs a removed line with its closest replacement so word-level diffs can be highlighted within a line. The optional Diff2HtmlUI layer (in src/ui/, not shown above but referenced from the README) wraps this with DOM insertion, highlight.js, and synchronized-scroll behavior for side-by-side mode.

Tech Stack: TypeScript compiled to both CommonJS and ESM output plus browser bundles via Webpack, styled with a PostCSS pipeline (autoprefixer, cssnano) for the shipped CSS bundle. Runtime dependencies are minimal — diff for the underlying diff/patch primitives and @profoundlogic/hogan for Mustache templating — with highlight.js as an optional peer for syntax highlighting. The project also builds and deploys its own demo website (webpack.website.ts, Terraform config for hosting) alongside the library.

Code Quality: Tests live under src/__tests__/ with one suite per major module (diff-parser-tests.ts, line-by-line-tests.ts, side-by-side-printer-tests.ts, file-list-renderer-tests.ts, hogan-cache-tests.ts, utils-tests.ts, diff2html-tests.ts), run via Jest with coverage (test:coverage) gating the validate script that also runs ESLint and Prettier checks before every version bump (preversion hook). GitHub activity shows the repo is mature (created 2014, 791 total commits, 87 releases) but currently in a low-activity/maintenance phase rather than active feature development.

API Design: The core API is deliberately small — parse() and html() — with all formatting controlled through a single Diff2HtmlConfig options object (output format, color scheme, matching strategy, etc.), so most consumers need only one function call. The optional Diff2HtmlUI class trades that minimalism for convenience, handling DOM mounting and highlight.js wiring directly so browser users don’t have to hand-assemble the pipeline themselves.

Used by 7 apps in this directory

TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,622

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
87
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated 5 days ago
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,299

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
63
Dependency
Built with
TypeScript97%
Updated yesterday
Go
62%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,251

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
64
Dependency
Built with
Go62%
TypeScript34%
Updated 3 days ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,586

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
89
Repo Health
86
Technical
62
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
95%
MIT

melty

Developer Tools · AI Code Assistants · Code Editors

5,443

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
67
Dependency
Built with
TypeScript95%
Updated 1 years ago
Go
40%
Apache 2.0

Rill

Analytics · Data Engineering

2,867

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
64
Dependency
Built with
Go40%
TypeScript37%
Svelte22%
Updated 2 days ago
Vue
47%
AGPL 3.0

Wiki.js

Knowledge Management · Collaboration

28,848

A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.

View details
72
Repo Health
67
Technical
60
Dependency
Built with
Vue47%
JavaScript42%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search