pipr.tools
Pipes
Clean Email Strip formatting from pasted email for clean plain text Clean AI Output Clean plain text from ChatGPT or AI output Decode & Format JWT Decode a JWT and pretty-print header and payload Word Frequency Count word frequency in text

diff Diff two text blocks line by line

Aa Text
Input0 chars
Output0 chars

Examples

Compare two text blocks line by line

Usage
"the quick brown fox
jumps over
the lazy dog
---
the quick re..." | diff

Compare two versions of marketing copy

Usage
"Our product helps teams work faster.
Built for modern workfl..." | diff

Spot changes between two versions of a company policy

Usage
"PTO: 15 days
Remote: 2 days/week
Bonus: up to 10%
---
PTO: 2..." | diff
View source
async (input)=>{
                const sep = input.indexOf("\n---\n");
                if (sep === -1) return "Error: separate two text blocks with a line containing only ---";
                const oldText = input.slice(0, sep);
                const newText = input.slice(sep + 5);
                const { diffLines } = await import('diff').then(async (m)=>{
                    await m.__tla;
                    return m;
                });
                const changes = diffLines(oldText, newText);
                const result = [];
                for (const part of changes){
                    const prefix = part.added ? "+ " : part.removed ? "- " : "  ";
                    const lines = part.value.replace(/\n$/, "").split("\n");
                    for (const line of lines)result.push(prefix + line);
                }
                return result.join("\n");
            }