EditSafely

Flatten a List

Remove all indentation levels.

Runs on your device, nothing uploaded

One dash per level, so - bananas sits one level in.
Try:

0 chars · 0 lines

Output

Remove all indentation levels.

Type or paste above to see the result here.

Example: Flatten a nested list

What you paste never leaves this tab

Flatten a List is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. On a normal site, the text you paste is sent to a server that can log it, cache it or keep it. Here it is read and transformed inside this tab and nowhere else.

  • No upload
  • No length limit
  • Works offline once loaded
  • Nothing stored or logged

How to use Flatten a List

  1. 1. Paste your indented list. Put your nested or indented list into the input pane, such as a tree of items where sub-items are indented under their parent.
  2. 2. Decide what else to remove. Turn on Drop empty items to remove blank lines as well, and Also remove bullets and numbers to strip markers such as - or 1. that sat inside the indentation.
  3. 3. Keep the levels if you need them. Under More options, Mark the depth with dashes puts one dash per level in front of nested items, so the outline shape survives as plain text.
  4. 4. Copy the flattened list. Copy the output, with every line's leading whitespace stripped so all items sit at the same level, ready for tools that expect a flat list.

When to use Flatten a List

Flatten a List strips leading whitespace from every line, turning a visually nested list into one flat sequence of items at the same indentation level. Use Flatten a List whenever indentation was meaningful for reading but is now getting in the way of processing.

  • Preparing a nested outline for a CSV import. An outline exported from a notes app has sub-items indented under headings, but the CSV importer needs one flat item per row. Flatten it before pasting into the importer.
  • Cleaning up copy-pasted code or config for a wordlist. You copied a tree-structured list where items were indented under categories and just need the plain values. Flatten the list to strip the indentation and keep the words.
  • Undoing accidental indentation from a text editor. Auto-indent in your editor added leading spaces to a list you did not want nested. Flatten the list to reset every line back to the left margin.
  • Simplifying a tree view export before further processing. A file tree or folder listing was copied with indentation showing depth, but a script needs a flat list of names. Flatten it and drop empty items before scripting further.

Examples

Flatten a nested list

Input

apples
  - bananas
    - cherries

Output

apples
- bananas
- cherries

Flatten and remove bullets

Input

apples
  - bananas
    - cherries

Output

apples
bananas
cherries

About the Flatten a List tool

Flatten a List does its work locally, right in the browser. Remove all indentation levels. There is no upload step, no queue and no account, and your data never travels over the network.

It belongs to the List Tools collection on EditSafely, a set of 114 small, focused List utilities that share the same instant, private workspace.

You can shape the output with 3 settings, including Drop empty items, Also remove bullets and numbers and Mark the depth with dashes, and the result refreshes the moment you change one. 2 worked examples further down the page show exactly what the tool produces for real inputs.

Running locally also makes the tool fast and dependable: results appear as soon as your input does, 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 List cost anything?

Yes, it is completely free. All 2,943 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; your device's memory is the ceiling. Up to 10 MB the result updates as you type, after a short pause that grows with the size. Above 10 MB a Run button appears so typing stays smooth, and files open up to 50 MB. A very long result shows its first 2,000 lines on screen, while Copy and Download always include all of it.

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.

Related tools

All List Tools →