JSON Array Flattener

Flattens arbitrarily nested arrays (an array of arrays of arrays...) into a single-level array, similar to JavaScript's Array.prototype.flat(), directly on JSON text. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

Overview

Introduction

Arrays of arrays show up whenever data gets grouped or paginated in stages, batches of batches, pages of results, categories of items, but a lot of downstream processing just wants one flat list.

This tool collapses that nesting directly on JSON text, without needing to write a script or open a REPL.

What Is JSON Array Flattener?

A flattener that recursively merges nested arrays into a single-level array, leaving non-array items untouched in their relative order.

It mirrors the behavior of JavaScript's native Array.prototype.flat() method, applied fully rather than to a fixed depth by default.

How JSON Array Flattener Works

The tool walks the top-level array item by item; whenever it encounters a nested array, it recurses into it and splices its items into the output in place, rather than keeping it as a single nested element.

Non-array items are pushed directly into the output array unchanged, preserving their original left-to-right order relative to everything else.

When To Use JSON Array Flattener

Use it when you have paginated or grouped API results (an array of pages, each page an array of items) and just want one flat list of items.

It's also useful for quickly checking how many total leaf items exist across a nested array structure.

Features

Advantages

  • Flattens completely by default, no matter how many levels of nesting.
  • Preserves the relative order of items exactly as encountered.
  • Leaves non-array items untouched, so mixed content flattens predictably.

Limitations

  • Only flattens array nesting; nested objects containing arrays are not affected.
  • There's no way to flatten to a partial depth from the tool's UI; it's all-the-way or nothing.

Examples

Flattening a nested array

Input

[1,[2,3,[4,5]],[6,[7,[8,9]]]]

Output

[1,2,3,4,5,6,7,8,9]

Every level of array nesting is merged into a single flat list, regardless of depth.

Best Practices & Notes

Best Practices

  • Confirm your data is actually array-of-arrays before flattening; a top-level object needs Flatten a JSON Object instead.
  • If order matters for later processing, verify the flattened order still matches your expectations, since flattening is strictly left-to-right.
  • Use Analyze JSON first if you're unsure how deeply nested your array actually is.

Developer Notes

The flatten() helper recurses only into Array.isArray() values, explicitly leaving plain objects untouched even if they contain arrays internally; this keeps the tool's behavior narrowly scoped and predictable rather than trying to guess at a more general flattening strategy across mixed array/object nesting.

JSON Array Flattener Use Cases

  • Merging paginated API results into one flat list of items
  • Collapsing grouped or categorized data into a single array for processing
  • Simplifying a deeply nested array before further transformation

Common Mistakes

  • Using this on a top-level object expecting it to flatten nested arrays inside; it requires a top-level array.
  • Assuming objects inside the array also get flattened; only array-in-array nesting is affected.
  • Losing track of which original group an item came from, since flattening discards that grouping information by design.

Tips

  • If you need to know which group an item originally came from, tag items before flattening rather than trying to recover that after.
  • Pair with Extract JSON Values if you also want to strip out any remaining object structure from the flattened items.

References

Frequently Asked Questions