Overview
Introduction
A pasted list sometimes contains grouped sub-items marked off in brackets, like "[a,b],c,[d,e]", that really should become individual top-level entries.
List Flattener unwraps exactly that structure, expanding every bracketed sub-list into its own separate items while leaving plain items untouched.
What Is List Flattener?
A restructuring tool that treats any item enclosed in [...] as a sub-list and expands its comma-separated contents into individual top-level items.
It's bracket-aware when splitting the outer list too, so a comma inside brackets is never mistaken for the outer separator, even when the outer separator is itself a comma.
How List Flattener Works
The input is split on the resolved outer separator using a bracket-depth-aware scanner, so delimiters inside an open [ ... ] span never split the sub-list apart prematurely.
Each resulting top-level item is checked for a leading [ and trailing ]; if both are present, the bracket contents are split on commas, trimmed, and each piece becomes its own item, replacing the original bracketed entry.
When To Use List Flattener
Use it when a pasted or generated list groups related items in brackets and you need every item flattened into one flat sequence.
It's also useful for cleaning up ad hoc data exports that represent grouped values with bracket notation.
Often used alongside Sublist Extractor, List Splitter and List Splicer.
Features
Advantages
- Correctly handles commas both inside and outside brackets, even when they'd otherwise collide with the outer separator.
- Leaves plain (non-bracketed) items completely untouched, so only genuine sub-lists are expanded.
- Drops genuinely empty sub-lists (like an empty []) rather than inserting a stray blank item.
Limitations
- Only flattens one level; nested brackets within brackets aren't recursively unwrapped.
- Sub-list contents must be comma-separated; a bracketed group using a different internal delimiter won't be recognized as a sub-list.
Examples
Best Practices & Notes
Best Practices
- Use square brackets consistently to mark sub-lists; unbalanced or missing brackets on an item leave it as a single plain item instead.
- Run the tool twice if you have two levels of nesting to unwrap, since only one level is flattened per pass.
Developer Notes
A custom bracket-depth-aware scanner (not the shared splitListItems helper) walks the input character by character, tracking `[`/`]` depth so the outer delimiter is only recognized at depth 0, before falling back to a plain comma split for each bracketed item's contents.
List Flattener Use Cases
- Expanding grouped values from a data export that uses bracket notation for sub-groups
- Flattening ad hoc "category: [items]" style pasted data into one flat list
- Cleaning up manually typed lists where related items were grouped in brackets for readability
Common Mistakes
- Expecting recursive flattening of doubly-nested brackets; only one level is unwrapped per run.
- Using a delimiter other than a comma inside brackets and expecting it to be recognized as a sub-list separator; inner items must be comma-separated.
- Forgetting that an outer comma separator still works correctly with bracketed commas thanks to the bracket-aware scanner, no need to switch to newline separation just to avoid collisions.
Tips
- Run the tool a second time on its own output if you have two levels of bracket nesting to fully flatten.
- Use an empty bracket pair [] intentionally to represent (and drop) a placeholder empty sub-list.