is an option to Diff and related functions that indicates with what granularity to compare the given expressions.


DiffGranularity
is an option to Diff and related functions that indicates with what granularity to compare the given expressions.
Details

- Valid settings for DiffGranularity depend on the expressions being compared.
- Settings for DiffGranularity include:
-
"Lists" compare lists by item "Characters" compare strings character by character "Words" compare strings one word at a time "Lines" compare strings or files one full line at a time "Cells" compare one Cell with another "Notebooks" compare one Notebook with another - The default setting of Automatic will choose an appropriate granularity for the given expressions.
- The default granularity depends on the heads of the expressions being diffed:
-
List "Lists" String "Characters" BioSequence "Characters" Cell "Cells" ExpressionCell "Cells" TextCell "Cells" CellObject "Cells" Notebook "Notebooks" NotebookObject "Notebooks" File["file.nb"] "Notebooks" File[other] "Lines"
Examples
open all close allBasic Examples (1)
By default, strings are compared as a sequence of characters:
Use DiffGranularity to treat strings as a sequence of lines instead:
Properties & Relations (1)
Use DiffGranularity to perform a diff of the raw text of notebook files, line by line:
History
Text
Wolfram Research (2024), DiffGranularity, Wolfram Language function, https://reference.wolfram.com/language/ref/DiffGranularity.html.
CMS
Wolfram Language. 2024. "DiffGranularity." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DiffGranularity.html.
APA
Wolfram Language. (2024). DiffGranularity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiffGranularity.html
BibTeX
@misc{reference.wolfram_2025_diffgranularity, author="Wolfram Research", title="{DiffGranularity}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/DiffGranularity.html}", note=[Accessed: 13-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_diffgranularity, organization={Wolfram Research}, title={DiffGranularity}, year={2024}, url={https://reference.wolfram.com/language/ref/DiffGranularity.html}, note=[Accessed: 13-August-2025]}