Skip to main content

Redlines

Repository banner image PyPI - Version GitHub Release Date - Published_At GitHub last commit (by committer) PyPI - License

Redlines compares two strings/text and produces structured output showing their differences. Changes are represented with strike-throughs and highlights, similar to Microsoft Word's track changes. The output includes detailed change information, positions, and statistics for programmatic use.

Supports multiple output formats: JSON (default, with structured change data and statistics), Markdown, HTML, and rich (terminal display).

Quick Start

# Install
pip install redlines

# CLI: Compare two texts (outputs JSON by default)
redlines "The quick brown fox jumps over the lazy dog." "The quick brown fox walks past the lazy dog."

# Python: Compare and get markdown
from redlines import Redlines
test = Redlines(
    "The quick brown fox jumps over the lazy dog.",
    "The quick brown fox walks past the lazy dog.",
    markdown_style="none"
)
print(test.output_markdown)
# Output: The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog.

Supported: Python 3.10 - 3.14 (Python 3.8 and 3.9 support dropped)

Optional dependencies:

  • pip install redlines[pdf] for PDF file comparison
  • pip install redlines[nupunkt] for advanced sentence boundary detection (Python 3.11+, handles abbreviations, citations, URLs)
  • pip install redlines[levenshtein] for additional statistics

Usage

Python API

The library contains one class: Redlines, which is used to compare text.

Basic comparison:

from redlines import Redlines

test = Redlines(
    "The quick brown fox jumps over the lazy dog.",
    "The quick brown fox walks past the lazy dog.",
    markdown_style="none"
)
assert (
    test.output_markdown
    == "The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog."
)

Multiple comparisons with one source:

from redlines import Redlines

test = Redlines("The quick brown fox jumps over the lazy dog.", markdown_style="none")
assert (
    test.compare("The quick brown fox walks past the lazy dog.")
    == "The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog."
)

assert (
    test.compare("The quick brown fox jumps over the dog.")
    == "The quick brown fox jumps over the <del>lazy </del>dog."
)

JSON output with structured data:

from redlines import Redlines

test = Redlines(
    "The quick brown fox jumps over the lazy dog.",
    "The quick brown fox walks past the lazy dog."
)

# Get JSON with changes, positions, and statistics
print(test.output_json(pretty=True))

CLI

Basic usage (outputs JSON by default):

redlines "old text" "new text"
redlines file1.txt file2.txt --pretty

Output formats:

redlines text "source" "test"              # Rich terminal display
redlines markdown file1.txt file2.txt      # Markdown output
redlines stats old.txt new.txt             # Statistics only

Run redlines --help or redlines guide for the Agent Integration Guide. See also: redlines-textual.

Advanced Features

Custom Processors

Use NupunktProcessor for sentence-level tokenization with intelligent boundary detection:

from redlines import Redlines
from redlines.processor import NupunktProcessor

processor = NupunktProcessor()
test = Redlines("Dr. Smith said hello.", "Dr. Smith said hi.", processor=processor)

Sentence mode preserves the input's paragraph boundaries (fixed in 0.6.2): sentences are anchored within their paragraph, so the output is not reflowed one sentence per paragraph.

Use NupunktProcessor for: Legal/technical documents with abbreviations, URLs, citations, decimals Use WholeDocumentProcessor (default) for: Simple documents, speed-critical tasks (5-6x faster), paragraph-level granularity

See demo comparison for benchmarks.

For AI Agents & Automation

🤖 Using with AI coding agents? See the Agent Integration Guide for JSON schemas, automation patterns, error handling, and runnable examples. Agents fetching documentation as text can start at llms.txt.

Documentation & Resources

Full Documentation: https://houfu.github.io/redlines

Example Use Cases:

License

MIT License

Metadata

Release files for redlines 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redlines 0.6.2
File Size Uploaded Provenance Actions
redlines-0.6.2.tar.gz 517.6 kB With provenance Details for redlines-0.6.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redlines 0.6.2
File Interpreter ABI Platform Actions
redlines-0.6.2-py3-none-any.whl Python 3 none any Details for redlines-0.6.2-py3-none-any.whl

Total release size: 550.0 kB

Release files / redlines-0.6.2.tar.gz

Download URL redlines-0.6.2.tar.gz
Size 517.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1679acdef2ac97e3d02e43497c163e580b68a57fab0f753e6adc52508ce3cd69
BLAKE2b-256 checksum
How to use checksums
ecd9bdd4afb006d9182bd97833924bbbd22a77bf42b62c31afbc4327ee729178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / redlines-0.6.2-py3-none-any.whl

Download URL redlines-0.6.2-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1f72897f24ce6a612344497d54a4534393383a01a213303a0f01f038bb795f2
BLAKE2b-256 checksum
How to use checksums
b973eea007f7c8ab13c668a6d0984c0df6601f7379b80182ed265a0d7049d574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Security for redlines 0.6.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for redlines-0.6.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page