Developer Tools

Code Compare Tool

Live

Calculate line comparison from original code, revised code, ignore whitespace.

About Code Compare Tool

Calculate line comparison from original code, revised code, ignore whitespace. Enter original code, revised code, ignore whitespace in a purpose-built code compare tool interface designed for this subject. A line-level longest-common-subsequence comparison classifies added, removed, and unchanged lines. The result includes line comparison, added lines, removed lines, unchanged lines, supporting detail, and clear units or diagnostics. Results depend on the entered assumptions, units, supported input range, and rounding. Review important decisions against authoritative requirements. Processing stays in your browser, and UtilityPages does not store the values you enter.

Set up Code Compare Tool

Workspace

Source workbench

Edit the source fields below and inspect the rendered output alongside your work.

This workspace updates as you edit.

Enter original code.

Enter revised code.

Enter ignore whitespace.

Code Compare Tool result

Enter the values above, then process to see a detailed result.

How Code Compare Tool works

A line-level longest-common-subsequence comparison classifies added, removed, and unchanged lines.

How it works

A line-level longest-common-subsequence comparison classifies added, removed, and unchanged lines. Results depend on the entered assumptions, units, supported input range, and rounding. Review important decisions against authoritative requirements.

Examples

Code Compare Tool worked example

Example input
{
    "original": "const total = items.length;\nreturn total;",
    "revised": "const total = items.filter(Boolean).length;\nreturn total;",
    "ignore_whitespace": "no"
}
Expected result
{
    "diff": [
        {
            "type": "added",
            "original_line": "",
            "revised_line": 1,
            "text": "const total = items.filter(Boolean).length;"
        },
        {
            "type": "removed",
            "original_line": 1,
            "revised_line": "",
            "text": "const total = items.length;"
        },
        {
            "type": "unchanged",
            "original_line": 2,
            "revised_line": 2,
            "text": "return total;"
        }
    ],
    "added": 1,
    "removed": 1,
    "unchanged": 1
}

Privacy

This tool does not store your inputs or results on UtilityPages.org.

Citations & sources

  1. Web APIs

Frequently asked questions

How does the Code Compare Tool work?

A line-level longest-common-subsequence comparison classifies added, removed, and unchanged lines.

What information should I enter?

Enter original code, revised code, ignore whitespace. Use values and units from the same scenario so the result is internally consistent.

What results does this tool provide?

It reports line comparison, added lines, removed lines, unchanged lines, including intermediate context where it helps you review the answer.

What limitations should I know about?

Results depend on the entered assumptions, units, supported input range, and rounding. Review important decisions against authoritative requirements.