Overview
Introduction
Pairing up two related lists, like a list of keys and a list of values, into combined key:value entries is a common task when preparing data for another tool or format.
List Zipper does exactly this, interleaving two lists into pairs the same way Python's built-in zip() function does.
What Is List Zipper?
A list-pairing tool: it walks both lists in lockstep, joining the item at each matching position from List A and List B using a configurable glue string.
The output is one paired line per position, formatted as "itemA<glue>itemB", e.g. "a:1" with the default glue of ":".
How List Zipper Works
Both inputs are split into items using the shared selected separator, then paired up index by index: List A's first item with List B's first item, and so on.
Zipping stops as soon as the shorter of the two lists runs out, and each resulting pair is joined with the configurable glue string before being rejoined into the output list.
When To Use List Zipper
Use it to combine a list of keys with a list of values into ready-to-use "key:value" pairs.
It's handy for preparing paired data, like coordinates or labeled measurements, from two separately maintained lists.
Often used alongside List Unzipper, List Comparer and Common List Item Finder.
Features
Advantages
- Matches the well-known, predictable semantics of Python's zip(), including its shorter-list-wins truncation behavior.
- The glue string is fully configurable, not locked to a single fixed separator.
Limitations
- Truncates to the shorter list's length; it never pads the shorter list to match the longer one.
- If either list's items themselves contain the glue string, the pairing is still readable but List Unzipper will only split on the first occurrence when reversing it.
Examples
Best Practices & Notes
Best Practices
- Make sure both lists are the same length if you need every item represented; otherwise the extra tail of the longer list is silently dropped.
- Pick a glue string that won't appear inside your items, to keep List Unzipper's reverse operation unambiguous.
Developer Notes
Zips by iterating `for (let i = 0; i < Math.min(itemsA.length, itemsB.length); i++)`, building each pair as a template-literal string `${itemsA[i]}${glue}${itemsB[i]}`, directly mirroring Python's zip() truncate-to-shortest semantics.
List Zipper Use Cases
- Combining a list of keys with a list of values into paired "key:value" entries
- Pairing coordinates, like separate X and Y value lists, into combined points
- Preparing labeled data for import into another tool that expects paired entries
Common Mistakes
- Expecting the longer list's extra items to be kept or padded; they're always dropped, matching zip()'s standard truncation behavior.
- Choosing a glue string that also appears inside the list items, making the pairing ambiguous to reverse later.
Tips
- If your lists differ in length and you need every item preserved, pad the shorter list with placeholder values first.
- Use List Unzipper afterward with the same glue string to split the pairs back into two separate lists.