Flatten a JSON Array
Reduce the nesting level of an array of arrays. Runs entirely in your browser, so your data never leaves your device.
0 chars · 0 lines
Output
The result appears here as you type.
How to use Flatten a JSON Array
- 1. Paste your nested array. Paste a JSON array that contains other arrays inside it, whether it is one level deep or several. The tool reduces the nesting according to the level you choose.
- 2. Choose how many levels to flatten. Pick 1 level to merge only the outermost nested arrays into the parent, 2 levels to go one step further, or All levels to collapse every array, no matter how deeply nested, into a single flat list.
- 3. Pick the output indent and copy. Choose 2 spaces, 4 spaces or tabs for the Indent setting, then copy the flattened array and use it wherever a simple, single-level list is what your code actually needs.
When to use Flatten a JSON Array
Flatten a JSON Array reduces an array of arrays down to fewer levels of nesting, or all the way down to a single flat list. This is for data that arrived grouped, batched or paginated as nested arrays when your code just needs a plain list of items.
- Combining paginated API results. You collected results from several pages of an API and each page's items sit in its own array, so you now have an array of arrays that needs to become one flat list.
- Simplifying a grouped dataset for a chart library. Data arrived grouped into nested arrays by category, but the charting library you are using expects a single flat array of values to plot.
- Cleaning up output from a recursive script. A script that collects results recursively produced deeply nested arrays as a side effect, and you want a single flat list before passing the data downstream.
- Merging batched rows before a bulk insert. Records were split into batches, each stored as its own array inside a larger array, and a bulk database insert needs them as one flat array of rows.
Examples
Flatten one nesting level
Input
[[1, 2], [3, [4, 5]]]
Output
[
1,
2,
3,
[
4,
5
]
]About the Flatten a JSON Array tool
Flatten a JSON Array does its work locally, right in the browser. Reduce the nesting level of an array of arrays. There is no upload step, no queue and no account, and your data never travels over the network.
It belongs to the JSON Tools collection on EditSafely, a set of 90 small, focused JSON utilities that share the same instant, private workspace.
You can shape the output with 2 settings, including Flatten and Indent, and the result refreshes the moment you change one. A worked example further down the page shows exactly what the tool produces for a real input.
Running locally also makes the tool fast and dependable: results appear as you type or drop a file, there is no server outage that can take it down mid-task, and confidential data can be processed without a second thought.
Frequently asked questions
Does Flatten a JSON Array cost anything?
Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.
Is it safe to paste sensitive or confidential data?
No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.
How much text can I process at once?
There is no fixed limit. Because the work happens on your own device rather than on a shared server, the practical ceiling is your machine's memory, which comfortably handles inputs far larger than typical online tools allow.
Do I need to sign up or install anything?
Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.
How do I use the result?
The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.