Skip to content

Quickstart

redlines compares two strings and produces structured output showing their differences. Changes are represented with strike-throughs and highlights, in the manner of Microsoft Word’s track changes, and the output carries change information, positions and statistics for programmatic use.

Terminal window
pip install redlines

Python 3.10 to 3.14 are supported.

Extra Install What it adds
pdf pip install redlines[pdf] Comparing PDF files
nupunkt pip install redlines[nupunkt] Sentence boundary detection that handles abbreviations, citations and URLs (Python 3.11+)
levenshtein pip install redlines[levenshtein] Levenshtein distance in the statistics

JSON is the default output, so a bare invocation is enough:

Terminal window
redlines "The quick brown fox jumps over the lazy dog." "The quick brown fox walks past the lazy dog."

Files work the same way, and --pretty makes the JSON readable:

Terminal window
redlines --pretty old_version.txt new_version.txt
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)
# The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog.

Other output formats are available on the same object: output_json for structured changes and statistics, output_rich for terminal display, and compare(markdown_style=...) for the six markdown styles.

  • The agent integration guide covers invocation from agents and automation, the JSON structure, error handling and integration patterns.
  • The API reference is generated from the docstrings and documents every class and method.
  • The decision records explain why the library is shaped the way it is, and where it is going.

Every page is available as plain markdown by appending .md to its path — /guides/agent-guide.md, for instance. /llms.txt indexes the site, /llms-small.txt is the usage documentation in one file, and /llms-full.txt adds the planning documents and decision records.