Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Flatten JSON Array

Flatten nested arrays in JSON to a single flat array with configurable depth

Your data never leaves your browser
JSON Input0 chars, 0 lines
Flattened Output0 chars, 0 lines
Ready·

Paste a nested JSON array, pick your depth, and get a single flat list back — objects, strings, and numbers stay intact while the extra bracket layers disappear. Useful when you're merging API responses or cleaning up grouped query results that need to land in one flat structure.

And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste Nested Array
➔
Set Flatten Depth
➔
Get Flat Array

The tool parses your JSON, then recursively walks each element. When it hits a sub-array, it pulls the contents up one level. It keeps going until it reaches the depth you chose — or until there are no arrays left. Non-array values (objects, strings, numbers) pass through untouched.

Examples

Simple one-level nesting

You merged several tag lists and each source gave you a separate sub-array.

INPUT
[["html", "css"], ["js", "ts"], ["python"]]
OUTPUT
["html", "css", "js", "ts", "python"]

Mixed types with objects inside

API response came back with user groups nested in arrays, but the user objects themselves should stay intact.

INPUT
[[{"id": 1, "name": "Alice"}], [{"id": 2, "name": "Bob"}, {"id": 3, "name": "Carol"}]]
OUTPUT
[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}, {"id": 3, "name": "Carol"}]

Deeply nested with controlled depth

Three levels of nesting from a recursive category tree. You only want to flatten the first level and keep the rest grouped.

INPUT (Depth 1)
[1, [2, [3, [4]]], [5, [6]]]
OUTPUT
[1, 2, [3, [4]], 5, [6]]

Who Uses This

💻 Backend Developers

Normalizing nested API responses before inserting rows into a database.

📊 Data Analysts

Flattening grouped query results so they can be imported into a spreadsheet as one list.

🎓 Students

Learning how Array.flat() works by testing different depth values on sample data.

🛠️ QA Engineers

Verifying that a flattened payload matches expected test fixtures before filing a bug.

Common Mistakes

Pasting a JSON object instead of an array

If your top-level value is {} instead of [], the tool will reject it. Wrap the object in brackets — [{...}] — or extract the array property you actually need first.

Choosing "All levels" when you only need one

Full flatten destroys every level of grouping. If your inner arrays represent meaningful groups (like rows of cells), set depth to 1 so you collapse only the outer wrapper and keep the row structure.

Trailing commas in the input

JSON doesn't allow trailing commas. Something like [1, 2, 3,] will throw a parse error. Remove the last comma or run your input through a JSON fixer first.

Technical Details

Frequently Asked Questions

What does it mean to flatten a JSON array?

Flattening takes a nested array — arrays inside arrays — and merges them into one single-level list. Think of it like dumping several boxes of items onto one table. The items stay the same; you just remove the boxes.

Does flattening change objects inside the array?

No. Only array wrappers are removed. If you have an object like {"name": "Alice"} nested inside an array, the object itself is untouched — it just moves up to the flat list.

How is this different from JSON Formatter?

A JSON formatter changes how your JSON looks (indentation, spacing) without touching the structure. This tool changes the structure itself by collapsing nested arrays into one. Use the formatter when you need readability; use flatten when you need a different shape.

Can I flatten only the first level and keep deeper nesting?

Yes — that is exactly what the depth selector is for. Set it to "Depth 1" and only the outermost layer of arrays gets unwrapped. Everything deeper stays grouped as-is. Works just like JavaScript's Array.flat(1).

Is my data safe? Does it get sent anywhere?

Your data stays in your browser the entire time. There is no upload, no server call, nothing leaves your machine. Close the tab and it is gone. That makes it safe for proprietary or sensitive JSON payloads.

Share: