Merge two texts line by line

Merge two texts produces an alternating output: line 1 of A, then line 1 of B, then line 2 of A, then line 2 of B, and so on. Paste both texts into the input pane separated by a line of ---. The merge runs in your browser; nothing uploads. For a side-by-side comparison view use diff; to combine without interleaving see find common lines.

Input
Line 1:1 LF cloud_done Saved locally
Result Merge Two Texts
0 lines 0 chars

Interleave two lists into one

Merge two texts is useful when you have two parallel lists (questions and answers, English and translation, A column and B column) that need to be zipped together. The split between texts is a line containing exactly ---. The tool walks both halves in parallel; for each index it emits A's line first, then B's line.

When the two halves are unequal in length, the longer side is still emitted in full. If A has 5 lines and B has 3, output is A1, B1, A2, B2, A3, B3, A4, A5. Empty trailing lines on the shorter side do not produce extra blank rows; missing entries are simply skipped.

The output preserves every byte of each line, including leading and trailing spaces. Need a different combination strategy? See find common lines for set intersection or diff for change tracking.

How to use merge two texts line by line

  1. 1Paste text A into the input panel, then a line with ---, then paste text B.
  2. 2The interleaved output appears in the output panel, alternating A and B line by line.
  3. 3Click Copy in the output header to copy the merged text.
  4. 4Click Download to save the result as a plain-text file.
  5. 5For a Q&A or label/value pairing, put the labels in A and the values in B.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

How the merge works

Strict interleave order

For every index i the tool emits A[i] then B[i]. The pattern is A, B, A, B, A, B regardless of content.

Unequal lengths handled gracefully

If A is longer than B, the trailing A lines are emitted on their own. If B is longer, the trailing B lines come last. No padding lines are inserted.

Lines emitted verbatim

Each line is passed through unchanged, including leading and trailing whitespace. Tabs, mixed scripts, and emoji come through intact.

Three-hyphen separator

Both halves go in the same input pane, separated by a line containing exactly ---. Without it the tool returns a prompt asking for two halves.

Plain-text output

Output is plain text with one entry per line, ready to paste into a spreadsheet, a study deck, or another tool.

Worked example

Lines alternate A then B at each index. To combine into shared lines instead of an alternating pattern, see find common lines.

Input
red
green
blue
---
one
two
three
Output
red
one
green
two
blue
three

Settings reference

Behaviour Effect on output
Separator A line containing exactly --- splits text A from text B.
Order A[i] then B[i] at each index.
Unequal lengths Longer side's extra lines emitted at the end without padding.
Whitespace Each line passes through unchanged.
Empty lines Treated as a line and emitted in turn.
Line endings CRLF and LF accepted; output uses LF.
Missing separator Output prompts for two halves split by ---.

FAQ

What if my two texts have a different number of lines?
The merge still runs. Once the shorter side is exhausted, only the longer side's remaining lines are emitted, in order, with no padding.
Can I interleave by paragraph instead of by line?
Not directly. Convert paragraphs to single lines first, or merge twice with paragraph breaks reinserted afterwards.
Does it deduplicate?
No. Every line from both sides goes into the output. To collapse repeats afterwards use remove duplicate lines.
Does it preserve trailing whitespace?
Yes. Each line is emitted exactly as pasted, including trailing spaces and tabs.
How do I undo the merge?
Take every other line. There is no built-in unmerge in this tool, but a sort followed by a manual split is usually enough for short lists.