Diffs, from Pierre

Diffs, from Pierre

NEW

@pierre/diffs is an open source diff and code rendering library. It's built on Shiki for syntax highlighting and theming, is super customizable, and comes packed with features.

Created Jun 01, 2026
Updated Jun 08, 2026

What it is

@pierre/diffs is an open-source JavaScript library for rendering code diffs and patches. It is built on Shiki for syntax highlighting and theming, and is designed for use in web applications that need to display code changes—such as code review tools, version control interfaces, and collaborative editing environments. The library is maintained by The Pierre Computer Company.

Main Features

Layout & Rendering

  • Supports stacked (unified) and split (side-by-side) diff layouts, implemented with CSS Grid and Shadow DOM for reduced DOM nodes and faster rendering.
  • Adapts automatically to any Shiki theme, including support for light and dark color modes.

Change Styling

  • Renders changed lines with classic diff indicators (+/), full-width background colors, or vertical bars.
  • Can highlight inline changes at the character or word level.
  • Options to toggle line wrapping, hide line numbers, and control other display settings.

Theme & Typography

  • Integrates directly with Shiki for syntax highlighting and theming.
  • Respects global or per-component CSS font settings, including font-family, font-size, line-height, and font-feature-settings.

Hunk Separators

  • Provides built-in styles for collapsed chunk separators (e.g., line info, basic metadata, simple custom CSS) and supports a CSS-only custom variant.

Custom Headers

  • Offers lightweight header metadata rendering and supports fully custom headers rendered inside the built-in data-diffs-header container.

Merge Conflict Resolution

  • Includes a dedicated diff primitive for merge conflicts, treating current and incoming sections as structured additions/deletions.
  • Users can resolve by choosing current, incoming, or both changes and preview the merged file immediately.

Annotations & Interactivity

  • Comments & Annotations: Framework for injecting additional content (e.g., line comments, CI annotations) into the diff.
  • Accept/Reject Changes: Supports interactive code review interfaces where each change can be accepted or rejected with visual feedback.
  • Line Selection: Clicking a line number selects it; click-and-drag or Shift+click for multi-line selection, with programmatic control.
  • Token Hover: Attach hover callbacks to individual syntax tokens to show tooltips or other contextual information.

File Comparison

  • Can diff any two arbitrary files (not limited to Git diffs or patches), useful for comparing generative snapshots or non-linear histories.

How it works

Installation & Integration

  • Install via: bun i @pierre/diffs (currently version 1.2.5).
  • Use the library's components in a web application to render diffs with minimal setup—pass the original and modified code or a standard diff format.

Typical Usage Scenarios

  • Code review tools: Display pull request diffs with customizable styling, inline comments, and accept/reject workflows.
  • Version control interfaces: Show commit diffs with syntax highlighting and theme adherence.
  • Collaborative editing: Render real-time changes between file versions, including conflict resolution UI.
  • Educational content: Diff arbitrary files to illustrate code changes in documentation or tutorials.

Configuration

  • Developers configure the library via JavaScript/TypeScript options, such as layout type, theme, change indicators, font settings, and annotation callbacks.
  • The library outputs styled DOM elements that can be embedded into existing pages.

Key Points

  • Built on Shiki, ensuring robust syntax highlighting and easy theming.
  • Uses CSS Grid and Shadow DOM for efficient rendering.
  • Highly customizable—change indicators, hunk separators, headers, and annotation framework are all configurable.
  • Includes interactive features like line selection, token hover, and merge conflict resolution out of the box.
  • Supports both standard Git diffs and arbitrary file comparisons.
  • Open-source with a permissive license (not explicitly stated, but implied by the "open source" mention).

Additional Details

  • Version: 1.2.5 (as of the webpage).
  • Package manager: Installable via bun, but likely compatible with npm/yarn as well.
  • Documentation: Available on the project website.
  • Community: Discord server, GitHub repository, and X (Twitter) presence.
  • Attribution: Created by The Pierre Computer Company, whose team has experience from companies like Cloudflare, Coinbase, Discord, GitHub, Reddit, Stripe, and X.
Quick Actions
Table of Contents

Recommended Apps

Smart Algorithm