Find the LCS of Two Strings
Find the longest common subsequence of the first two lines. Runs entirely in your browser, so your data never leaves your device.
0 chars · 0 lines
Output
The result appears here as you type.
How to use Find the LCS of Two Strings
- 1. Paste two lines to compare. Enter your first string on the first line and the second on the second line of the input pane; the tool works from just these two lines.
- 2. Read how the result is computed. The tool finds the longest sequence of characters that appears in both strings, in the same relative order, though not necessarily consecutively.
- 3. Copy the common subsequence. Copy the resulting shared subsequence and use it wherever you need to see or reference exactly what the two strings have in common structurally.
When to use Find the LCS of Two Strings
Find the LCS of Two Strings computes the longest common subsequence shared between two lines of text. It is the same algorithm behind most diff tools, exposed directly for anyone who wants to see the shared structure rather than a highlighted diff.
- Understanding how a diff algorithm sees two strings. You are learning how tools like git diff work under the hood and want to see the actual longest common subsequence computed from two example strings.
- Measuring similarity between two data records. You are deduplicating a dataset and want to see the shared subsequence between two similar-looking entries to judge whether they represent the same underlying record.
- Debugging a sequence alignment algorithm. You are implementing an LCS-based algorithm yourself and want a known-correct reference result for two test strings to check your implementation against.
- Comparing two versions of a DNA-like sequence. You are working with sequence data represented as strings and want to find the longest matching subsequence between two variants for a bioinformatics-style exercise.
Examples
Common subsequence
Input
ABCBDAB BDCAB
Output
BCAB
About the Find the LCS of Two Strings tool
Find the LCS of Two Strings runs as plain JavaScript in your browser tab, with no server behind it. Find the longest common subsequence of the first two lines. Whatever you put in stays on your device from start to finish.
The tool is part of EditSafely's String Tools section, 159 single-purpose utilities built around the same idea: open the page, get the result, keep your data to yourself.
There is nothing to configure. Provide the input and the result appears on its own. A worked example further down the page shows exactly what the tool produces for a real input.
That local-first design has practical benefits beyond privacy. The tool keeps working on a flaky connection once the page has loaded, results are instant because nothing round-trips to a server, and it is safe to use with confidential material.
Frequently asked questions
Is Find the LCS of Two Strings free to use?
Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.
Is it safe to paste sensitive or confidential data?
Everything happens locally. Your browser downloads the tool's code once, then does all the processing itself; nothing you enter is transmitted, stored or logged. You can even go offline after the page loads and it will still work.
How much text can I process at once?
There is no fixed limit. Because the work happens on your own device rather than on a shared server, the practical ceiling is your machine's memory, which comfortably handles inputs far larger than typical online tools allow.
Do I need to sign up or install anything?
No. The tool works in any modern browser on desktop, tablet or phone. There is no account to create, no extension to add and no software to install.
How do I use the result?
The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.