JSON Value Swapper
JSON Value Swapper swaps the values of two fields across JSON objects in bulk. The redesigned workbench auto-detects the target array or object and lists its swappable fields: two clicks pair Field A with Field B, and the result updates live on the right. Multiple pairs, missing-key policies and indentation are all adjustable, and a Swap preview shows every change row by row.

:::tip 30-second quickstart
- Paste or drop JSON (an array of objects, or an object containing an array / a single object)
- Click the first field under Discovered fields for Field A, then a second field for Field B
- Optionally click Add swap pair to handle several pairs at once
- Optionally expand Advanced settings to pick a missing-key policy and JSON indentation
- Read the live result: JSON / Swap preview, copy, export, or use Result ➔ Source to write it back :::
Workbench at a glance
- Left: input area → Target data → Discovered fields → Swap pairs → Advanced settings
- Right: result area with a JSON / Swap preview switch plus Result ➔ Source, Copy, Copy node and Export
- Input header: Format JSON, Upload and Clear all; the whole input card accepts dropped files
- Live results: there is no Start button — editing the JSON, pairing fields or changing a policy recalculates instantly
How to use
1. Input JSON data
- Paste JSON, or drop a
.json/.txtfile anywhere on the input card; Upload works too - JSON5 syntax is accepted (comments, trailing commas, single quotes, unquoted keys)
- Format JSON re-indents the input with two spaces (disabled while the JSON is invalid)
- Clear all wipes the source, the target data, the swap pairs and the preview filters
- Invalid JSON shows "Invalid JSON format" under the input and in the result pane
- When no usable objects exist, the tool reports "No objects with swappable fields were found in this JSON. Provide an array of objects or a JSON object."
- With an empty input, the right pane offers three example cards — Swap first & last name, Fix swapped prices and Swap multiple pairs — clicking one loads the JSON, target data and pairs at once
2. Pick the target data
- A top-level array of objects is the target directly (path
$): every object has its field values swapped, while non-object elements are skipped - A top-level object is scanned for arrays, which are listed in the Target data selector (path + object count); the objects inside the array are the unit of work
- When the object contains no usable array, the top-level object itself becomes the target and the badge reads "1 object"
- The selector only appears when there are several targets or the path is not
$; once chosen, the badge shows how many objects can be processed (e.g. "N items") - A wrapper object is preserved; only field values inside the target array / object are modified
3. Click Field A and Field B
- Discovered fields lists the top-level keys of the target objects; the chip badge shows the value type:
Aastring,#number,T/Fboolean,null,{}object,[]array,*mixed - The coverage number on the right (e.g.
2/3) means 2 of 3 objects carry that key; chips with incomplete coverage are dimmed - Clicking the first field fills Field A and moves the active slot to Field B; clicking a second field fills Field B and the result appears immediately
- You can also type key names directly into the Field A / Field B inputs, with discovered keys suggested as you type; field names are case-sensitive
- Before a pair is complete, the right pane shows "Pick two fields to swap" with quick-pick cards for the first 8 fields; click one to fill the active slot
- A pair with only one side filled shows Incomplete; filling the same field on both sides shows Same field and blocks the swap
4. Set the missing-key policy (optional)
- Expand Advanced settings and choose one of Skip item (default) / Move value / Fill null under Missing key handling
- Each policy has a one-line explanation; it only affects objects that have just one side, while objects missing both fields never change
- The same panel also changes JSON indentation: 2 spaces (default) / 4 spaces / Compact; a Reset defaults button appears after any change
- The policy and indentation are remembered in your browser for next time
5. Review, copy and export
- Results recalculate live; the header badge shows "N swapped" (swap + move + fill-null operations, including same-value cases); when no pair can run the result pane shows an error hint instead of output
- When missing keys exist, a "N missing key" badge is added
- The JSON view shows the complete output in a read-only box with character and line counts; missing keys or unmatched pairs raise yellow notices
- The Swap preview lists each object's before and after values for every pair, with Swapped / Missing key / All filters and a search box
- Result ➔ Source overwrites the input area with the result (only enabled when values actually changed); Copy copies the full output, Copy node strips the outer
{}/[], and Export savesjson_value_swapper.json
Target data and field discovery
Target detection
- Top-level array: used as the target when it has at least one object element; only the objects are processed, while numbers, strings and null stay untouched
- Top-level object: the tool first scans object keys for arrays whose elements include objects and lists those arrays; if none exist it falls back to the top-level object itself
- A top-level empty array, a top-level array made only of scalars, an empty object and top-level scalars produce no target, and the result pane says no objects with swappable fields were found
- A nested array such as
$.productsis replaced in place: the wrapper object is preserved in the output
Discovered fields
- Only the first-level keys of the target objects are counted; nested object fields are not listed separately, but their values can be swapped as a whole
- The coverage number shows how many objects carry the key (displayed as
count/totalwhen there is more than one object); the sample comes from the first occurrence, with long text and containers shortened to a summary - With more than 8 fields a search box appears; the first 12 are shown by default with Show all N fields / Show fewer fields
- Very wide data is scanned up to 5,000 objects and at most 150 keys are listed; past that the tool asks you to type the key in the input box
Two-step click-to-pair
- A click fills the currently active slot; after Field A is filled the active slot moves to Field B
- A second click fills Field B and completes the pair
- Clicking the field already in the current slot again clears that slot; once every pair is full, clicking another field starts a new pair with that field in Field A
- The hint above the fields reads Click to fill Field A or Click to fill Field B, telling you where the next click will land
Swap pairs and multiple pairs
- Each pair is a card: the index and status badge sit top-left, with duplicate and delete actions on the right (delete is disabled when only one pair remains)
- The card holds the Field A / Field B inputs, with a ⇄ button between them to flip the two fields
- Below the inputs a sample shows Field A's old → new value and Field B's old → new value, so you can confirm the swap direction at a glance
- Add swap pair appends a row; Clear pairs resets to a single empty pair
- Multiple pairs run top to bottom, and later pairs see the result of earlier ones; for example
a ⇄ bthenb ⇄ cends withaholding the originalb,bthe originalcandcthe originala - A pair with only one side filled shows Incomplete and is skipped; identical fields show Same field; a pair whose fields exist nowhere shows Neither field found
Missing-key policies
- Skip item: only objects containing both Field A and Field B are swapped; objects missing either side stay unchanged. If no object has both sides, the whole pair fails with a missing-field error
- Move value: when an object has one side, its value moves to the other side and the original key is removed; the pair runs as long as at least one object has one side
- Fill null: when an object has one side, its value moves to the other side and the original field becomes null; it also runs as long as one side exists somewhere
- Swap preview row statuses: Swapped (both sides present with different values), Same value (both sides present with equal values), Missing key, Moved, Filled null
- The header count "N swapped" is the number of processed operations (swap + move + fill null), including same-value cases
Result views: JSON and swap preview
- JSON: the complete output, read-only; with missing keys a notice reads "N items are missing one or both fields" and its View preview button jumps to the missing rows; unmatched pairs add a separate "N pair(s) matched no fields and were skipped" notice
- Swap preview: shows before and after values row by row
- Filters: Swapped (N) (hides missing rows), Missing key (N) (only shown when missing keys exist), All (N)
- A search box appears when there are more than 5 rows and filters by field names or before / after values
- Columns:
#, Pair (only when more than one pair succeeded), Field A, Field B and Status; with a single pair the headers show the actual field names - Each cell shows "old → new"; same-value and missing rows are dimmed
- The table shows the first 300 rows only — use the JSON view or copy / export for the full output
Field syntax and limits
- Field A and Field B must be direct keys of the target objects; values can be any JSON type (string, number, boolean, null, object, array) and are moved as a whole
- Paths in the Target data selector use the
$/$.products/$['special-list']form and only choose the data scope — they cannot be typed into the field inputs - Leading and trailing spaces are trimmed from field names, so two keys cannot be distinguished by whitespace
Things to know
- Live results: there is no Start button — any input, pairing or policy change recalculates immediately, and Copy / Export always take the current complete output
- The input is not rewritten automatically: swapping happens in the result only; click Result ➔ Source to write it back
- Number precision: JSON numbers are parsed as floating point, so integers beyond the safe range (snowflake IDs, for example) may lose precision while parsing and in the output; the tool warns you. Store such IDs as strings when exactness matters
- Non-object elements: numbers, strings and null inside the array stay as-is and take no part in field discovery or swapping
- Remembered settings: the missing-key policy and JSON indentation are saved in your browser; the target data, pairs and preview filters only live on the current page and are not kept after a reload
- Everything runs locally in your browser — input never leaves your machine
Pairing with other JSON tools
- To copy one field's value into another field instead of swapping: JSON Field Value Mapper
- To edit fields inside nested objects: JSON Node Bulk Edit
- To sort or group by fields before swapping: JSON Sort & Group
- To translate i18n JSON into multiple languages: JSON Translate

