Skip to main content

Nested JSON Columns

When VisiData loads JSON with nested objects or arrays, they appear as raw string representations. Use expand commands to flatten them into individual columns or open them as child sheets.

Learning Focus

Use ( to expand a nested dict column into sub-columns. Use zM to expand a list column into multiple rows. Use Enter to drill into any nested cell as a child sheet.

Sample Data

[
{"id": 1, "name": "Alice", "address": {"city": "Singapore", "country": "SG"}, "scores": [92, 87, 95]},
{"id": 2, "name": "Bob", "address": {"city": "KL", "country": "MY"}, "scores": [75, 80, 78]},
{"id": 3, "name": "Carol", "address": {"city": "Jakarta", "country": "ID"}, "scores": [88, 91, 85]}
]

Before expansion, VisiData shows:

id name address scores
1 Alice {'city': 'Singapore', 'country': 'SG'} [92, 87, 95]
2 Bob {'city': 'KL', 'country': 'MY'} [75, 80, 78]

Expand a Nested Dict (()

Press ( on a column containing dicts to expand it one level:

# Move cursor to 'address' column
(

After pressing (:

id name address_city address_country scores
1 Alice Singapore SG [92, 87, 95]
2 Bob KL MY [75, 80, 78]

Each key in the dict becomes a new column prefixed with the parent name.

Expand All Nested Columns (g()

g( # expand ALL columns containing dicts or lists one level

Deep Expansion (z()

For deeply nested structures (dicts within dicts):

z( 3 # expand current column to 3 levels deep
z( 0 # fully expand all levels

Collapse (), g))

) # collapse the current expanded column back
g) # collapse ALL expanded columns at once

Expand a List into Rows (zM)

A list column like scores: [92, 87, 95] can be expanded so each item becomes its own row:

# Move cursor to 'scores' column
zM

Before zM:

id name scores
1 Alice [92, 87, 95]

After zM (each score becomes a separate row):

id name scores
1 Alice 92
1 Alice 87
1 Alice 95

Press q to undo the expansion and return to the original rows.

Drill Into a Nested Cell (Enter)

Press Enter on any cell containing a dict or list to open it as a child sheet:

# Move cursor to Alice's 'address' cell: {'city': 'Singapore', 'country': 'SG'}
Enter

Child sheet opens:

key value
city Singapore
country SG

Press q to return to the parent sheet.

Export Flattened JSON to CSV

# Load nested JSON
# Expand all nested columns
g(

# Save as flat CSV
Ctrl+S
# Enter: /tmp/flattened.csv

The output CSV has one column per leaf field (e.g., id, name, address_city, address_country).

Quick Reference

KeyAction
(Expand current nested column one level
g(Expand ALL nested columns one level
z( NExpand current column to depth N (0 = fully expand)
)Collapse current expanded column
g)Collapse ALL expanded columns
zMExpand list column into multiple rows
EnterDrill into nested cell as child sheet
qReturn from child sheet / undo zM expansion

What's Next