Transform JSON arrays and objects
Search finds a path; Transform changes the data under that path.
In
Online JSON Viewer,
open Transform on an array or object in the tree to map
or reshape items with built-in recipes — or Advanced JS when you need
a custom map-style expression.
Per-path Transform
Transform applies at the node you selected, not to the whole document blindly. The result is written back into the JSON at that path, the editor text updates, and you can keep editing or download. Prefer a nested array or object when you only want to reshape one branch.
Recipes vs Advanced JS
Recipes cover common map operations without writing code, for example:
- Pluck field / Set / add field / Drop null fields — object-focused helpers (on arrays of objects, use Apply to to target which item types change).
- Wrap as object, Set value, Stringify, and coerce recipes (To string, To number, To boolean).
- Identity — no change (useful to inspect preview wiring).
Advanced JS accepts a map-style expression over each
item (with item and index). Under the hood
it is compiled with new Function and runs in your
browser. Only use expressions you understand; do not paste untrusted
code. Prefer recipes when they already do the job.
Preview and Revert
Before Apply, Transform shows a short preview of how the first items
would look. Review that sample, then apply. If the result is wrong,
use Revert last change in the viewer toolbar — the same
undo path as inline edits — to restore the previous document snapshot.
Array vs object
- Arrays — each element is mapped; object-focused recipes typically target plain-object items, while wrap / set value / coerce can rewrite other types depending on Apply to.
- Objects — recipes operate on the object’s values (or the object as a whole for some helpers). The UI locks type toggles where a recipe only applies to plain objects.
Double-click primitives for single-value edits; use Transform when you need a bulk map across children.
Large-array caution
Mapping tens of thousands of items can freeze the tab for a moment while the browser runs the transform and re-serializes JSON. Preview covers only a handful of items; Apply still walks the full array or object. For huge payloads, transform a smaller nested path first, confirm the recipe, then apply higher up — or work on a trimmed copy. Very large results may also prompt for confirmation before applying.
Transform is for reshaping data. To find keys without changing them, see Filter and search JSON. Documents stay in the browser; edit JSON locally explains the privacy boundary.