Skip to main content

array-operations

Array operations β€” union, intersection, difference, symmetric difference β€” answer common data-cleanup questions. "What emails are in list A but not list B?" β†’ difference. "What IDs appear in both?" β†’ intersection. "All unique values across both lists?" β†’ union. The ZTools Array Operations tool accepts two arrays (one item per line, or comma-separated, or JSON), runs the operation in the browser, and returns the result with counts. Case-sensitive or insensitive, trim-or-not, dedupe-or-keep-duplicates β€” all configurable.

Use cases​

Cross-reference user lists​

Marketing wants emails on List A but NOT on the unsubscribe list. Difference operation gives the answer instantly.

Find shared customers​

Two products, two CSVs of user IDs. Intersection shows users of both β€” your cross-sell candidates.

Spot drift in two configs​

Two YAML files list allowed origins. Symmetric difference reveals which entries are in one but not the other.

Validate a migration​

Old DB had 10,234 records. New DB has 10,233. Difference points to the one record that didn't migrate.

How it works​

  1. Paste list A and list B β€” One item per line, comma-separated, or JSON array. Tool auto-detects format.
  2. Pick operation β€” Union (A βˆͺ B), Intersection (A ∩ B), Difference (A βˆ’ B), Symmetric Difference (A βŠ• B = items in exactly one).
  3. Configure matching β€” Case-sensitive (default), trim whitespace, treat numbers as numbers (so "1" matches 1).
  4. Read result β€” Output list plus counts: {input A: 1024, input B: 998, result: 76}. Copy as plain list or JSON.

Examples​

Input: A = [1,2,3,4]; B = [3,4,5,6]

Output: Union: [1,2,3,4,5,6]. Intersect: [3,4]. Aβˆ’B: [1,2]. Bβˆ’A: [5,6]. Symmetric: [1,2,5,6].


Input: A = emails subscribed; B = emails bounced

Output: Aβˆ’B = clean recipients. Use this list for the next send.


Input: Case-insensitive intersection of "Alice" and "alice"

Output: [Alice] (or [alice] β€” picks first occurrence). Without case-insensitive matching, the result would be empty.

Frequently asked questions​

How big can the lists be?

Browser memory is the limit β€” 1 million items per side works fine in modern browsers. The Set data structure makes operations O(n).

Does order of inputs matter?

Union and intersection: no. Difference: yes β€” Aβˆ’B differs from Bβˆ’A.

What about duplicates within a list?

By default, treated as a set (deduplicated). Toggle "preserve duplicates" if you need multiset semantics (e.g. counting).

Does it support objects?

Primitive comparison only β€” strings, numbers, booleans. For objects, key on a stable property (id) and operate on that array.

Privacy?

All processing in the browser. Emails / IDs / customer data never leave your device.

Tips​

  • For very large lists, paste as JSON arrays β€” faster than line-splitting in the browser.
  • Trim whitespace by default β€” accidental trailing spaces are the #1 cause of "items don't match".
  • For approximate matching (fuzzy), use a fuzzy-search tool first to canonicalise, then array-op the cleaned lists.
  • Combine with the Find Duplicate Items tool when you need duplicates inside a single list, not across two.

Try it now​

The full array-operations runs in your browser at https://ztools.zaions.com/array-operations β€” no signup, no upload, no data leaves your device.

Open the tool β†—


Last updated: 2026-05-06 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub