Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • Compute Services
  • System Modeler
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

Wolfram Consulting

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Notebook Assistant + LLM Kit
    • Compute Services
    • System Modeler
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
Diff
  • See Also
    • Diff3
    • SequenceAlignment
    • Complement
  • Related Guides
    • String Manipulation
    • Sequence Alignment & Comparison
    • Biomolecular Sequences
    • Life Sciences & Medicine: Data & Computation
    • Text Analysis
    • See Also
      • Diff3
      • SequenceAlignment
      • Complement
    • Related Guides
      • String Manipulation
      • Sequence Alignment & Comparison
      • Biomolecular Sequences
      • Life Sciences & Medicine: Data & Computation
      • Text Analysis

Diff[first,second]

returns a representation of the diffs between first and second.

Diff[first,second,format]

represents the diffs in the indicated format.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
Appearance  
AppearanceElements  
DiffAlignmentMethod  
Show More Show More
DiffGranularity  
DiffIgnore  
DiffIncludeMatches  
DiffInputFunction  
DiffStyle  
ImageSize  
ImageSizeAction  
Scrollbars  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • Diff3
    • SequenceAlignment
    • Complement
  • Related Guides
    • String Manipulation
    • Sequence Alignment & Comparison
    • Biomolecular Sequences
    • Life Sciences & Medicine: Data & Computation
    • Text Analysis
    • See Also
      • Diff3
      • SequenceAlignment
      • Complement
    • Related Guides
      • String Manipulation
      • Sequence Alignment & Comparison
      • Biomolecular Sequences
      • Life Sciences & Medicine: Data & Computation
      • Text Analysis

Diff

Diff[first,second]

returns a representation of the diffs between first and second.

Diff[first,second,format]

represents the diffs in the indicated format.

Details and Options

  • Diff produces results for the following types of expressions:
  • lists{…}returns differences between two lists
    text"text", File["fname.txt"]returns differences in individual characters, words or lines between two blocks of text
    biomolecular sequencesBioSequence[…]returns differences in letter strings between two biomolecular sequences
    cellsCell[…], CellObject[…]returns differences in content, styles and options between two cells
    notebooksNotebook[…], NotebookObject[…], File["fname.nb"]returns differences in cells and options between two notebooks
  • Diff returns a DiffObject.
  • Diff uses SequenceAlignment when comparing sequences of elements.
  • Diff supports all the options of SequenceAlignment, with the following additions: [List of all options]
  • DiffAlignmentMethod Automatichow to align the diff
    DiffGranularity Automaticthe granularity of the diff
    DiffIgnore {}list of data types that should be ignored
    DiffIncludeMatches Automaticwhether to include matching data in the resulting DiffObject
    DiffInputFunction Identitya function to preprocess the diff inputs
  • The visual display of the Diff output can be controlled with the following options:
  • Alignment{Automatic, Automatic}hwo to align objects in the display area
    AppearanceAutomaticthe overall appearance of the diff
    AppearanceElementsAutomaticwhat elements to include in the displayed diff
    DiffStyle<||>base style specifications for the diff
    ImageSizeAutomaticthe overall image size of the diff
    ImageSizeActionAutomaticwhat to do if the content size does not match the image size
    ScrollbarsFalsewhether to include scrollbars
    ScrollPosition{0,0}scrollposition if scrolling is enabled
  • When diffing text, DiffGranularity can be given settings of "Lines", "Words" or "Characters" to encode the differences into the resulting DiffObject accordingly. By default, if you are comparing two strings, you will get a "Characters" diff. If either of the objects is a text file, you will get a "Lines" diff.
  • When comparing notebooks, Diff uses extra knowledge about the structure of cells to determine how to align the cell lists of the two notebooks. By default, it looks at the ExpressionUUID of a given pair of cells for alignment. To align the cell lists by only matching the edit distances between cells, use DiffAlignmentMethod"CellEditDistance".
  • Diff[first,second] is equivalent to Diff[first,second,"DiffObjectViewer"], which produces a viewer with a popup menu allowing you to interactively select between different formats. Other values of format display as the given format, without the ability to interactively change the view type.
  • Some values of format display first and second explicitly, with inline annotations indicating the changes between the two:
  • "CharacterAlignment"for strings or biosequences, display individual characters of first and second vertically aligned with one another
    "Combined"display a combined version of first and second
    "Separate"display the list {first,second}
    "SideBySide"display elements of first and second in aligned, side-by-side columns
    "Unified"display elements of first and second in a single, unified column
  • Some values of format use abstract visualizations to depict the nature and extent of the changes between first and second:
  • "AlignmentChart"display a chart with elements of first and second depicted as columns of points with connecting lines to indicate how the elements align with one another
    "ArrayPlot"display a combined list of elements in an array plot, with colored array cells annotating the changes
    "SideBySideSummary"display first and second as separate sequences of colored array cells with long, unchanged sequences elided
    "UnifiedSummary"display first and second as a combined sequence of colored array cells with long, unchanged sequences elided
  • Other acceptable values of format include:
  • "Details"produce a textual description of each change
    "DiffObjectViewer"display in a panel with an interactive format setting
    "Report"create a notebook containing a report of the differences between two notebook expressions
    "SummaryBox"display as a DiffObject summary box
  • Some values of format will only work with a subset of expression types.
  • Diff[first,second][format] is equivalent to Diff[first,second,format].
  • List of all options

    • DiffAlignmentMethodAutomatichow to align the diff
      DiffGranularityAutomaticthe granularity of the diff
      DiffIgnore{}list of data types that should be ignored
      DiffIncludeMatchesAutomaticwhether to include matching data in the resulting DiffObject
      DiffInputFunctionIdentitya function to preprocess the diff inputs
      GapPenalty0additional cost for each alignment gap
      IgnoreCaseFalsewhether to ignore case of letters in strings
      MergeDifferencesTruewhether to combine adjacent differences
      Method"Global"alignment algorithm to be used
      SimilarityRulesAutomaticrules for similarities between elements

Examples

open all close all

Basic Examples  (3)

Find the diffs between two lists:

Find the diffs between two strings:

Format the DiffObject as a plain summary box:

Scope  (5)

Treat strings as a sequence of words instead of characters:

Compare two lists without regard to order or duplicates:

Find the lines where two text files differ:

Find the diffs between two cells:

Find the diffs between two notebooks:

Options  (15)

Appearance  (1)

Specify an initial appearance for the result:

AppearanceElements  (1)

The "Unified" format shows line numbers by default:

Remove the line numbers from AppearanceElements:

DiffAlignmentMethod  (1)

When a notebook contains multiple differing cells in a row, Diff attempts to find the best alignment:

Turning that feature off with DiffAlignmentMethod"SequenceAlignment" will result in two blocks of cells marked as a single change, without inner alignment:

DiffGranularity  (1)

By default, strings are compared as a sequence of characters:

Use DiffGranularity to treat strings as a sequence of lines instead:

DiffIgnore  (2)

When comparing cells, Diff will find style and option changes:

Use DiffIgnore to ignore all style and option changes:

Use DiffIgnore to ignore specific notebook options:

DiffIncludeMatches  (3)

When there are lots of matching elements, Diff does not include them all in the output:

Use DiffIncludeMatchesTrue to store all the matching elements:

DiffIncludeMatches also has an impact on the DiffObject for strings:

Displaying a diff will typically show all the matches included in the DiffObject:

DiffInputFunction  (2)

Compare the ExpressionCell rendering of arbitrary expressions:

Compare the InputForm strings of arbitrary expressions:

DiffStyle  (1)

Diff formats typically use green for additions and red for removals by default:

Use DiffStyle to add styling to particular elements:

Remove the default styling with the setting DefaultDiffStyle  None:

ImageSize  (1)

Specify a fixed height for the formatted content:

ImageSizeAction  (1)

Automatically shrink the display to fit in a fixed size:

Scrollbars  (1)

Set Scrollbars  Automatic to show scrollbars when necessary:

Properties & Relations  (5)

Ask a DiffObject for the list of available properties:

Extract a particular property:

Ask a DiffObject for the list of available formats:

Display a particular format:

Change the initial format of a DiffObject:

Return a visualization directly:

Given two lists, Diff and SequenceAlignment will find the same changes but represent them differently:

Extract the SequenceAlignment from the DiffObject:

Possible Issues  (2)

Diff compares strings as strings, even if they could be interpreted as file paths:

To compare the contents of the files instead, use File explicitly:

Diff will not attempt to compare objects of different types:

Neat Examples  (1)

Diff every pair of files in a list:

See Also

Diff3  SequenceAlignment  Complement

Related Guides

    ▪
  • String Manipulation
  • ▪
  • Sequence Alignment & Comparison
  • ▪
  • Biomolecular Sequences
  • ▪
  • Life Sciences & Medicine: Data & Computation
  • ▪
  • Text Analysis

History

Introduced in 2024 (14.1)

Wolfram Research (2024), Diff, Wolfram Language function, https://reference.wolfram.com/language/ref/Diff.html.

Text

Wolfram Research (2024), Diff, Wolfram Language function, https://reference.wolfram.com/language/ref/Diff.html.

CMS

Wolfram Language. 2024. "Diff." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Diff.html.

APA

Wolfram Language. (2024). Diff. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Diff.html

BibTeX

@misc{reference.wolfram_2025_diff, author="Wolfram Research", title="{Diff}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Diff.html}", note=[Accessed: 04-February-2026]}

BibLaTeX

@online{reference.wolfram_2025_diff, organization={Wolfram Research}, title={Diff}, year={2024}, url={https://reference.wolfram.com/language/ref/Diff.html}, note=[Accessed: 04-February-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English