Dedent List
Remove the leading whitespace every non-blank line shares, keeping relative indents.
What this page computes
Paste an indented block and the page removes the whitespace prefix that every non-blank line shares, then reports how many characters went. A line indented two spaces beyond that common prefix keeps its two extra spaces.
Where it stops
Dedent is not a trim. When the lines share no leading whitespace the page refuses instead of stripping each line, because there is no common prefix to remove. Tabs and spaces are compared as characters, so a mixed prefix stops at the first difference.
Why the answer repeats
The prefix is computed from the pasted lines in this tab and removed with string slicing, so the same paste always prints the same block. No line is uploaded or stored.
Removes the whitespace prefix shared by every non-blank line and reports its length, preserving the indentation that differs between lines. Lines with no common prefix are refused rather than trimmed.
How to use it
Paste the block and press Run. The first line says how many characters of common indent were removed; the rest is the dedented copy.
The arithmetic
The common prefix is the longest string of leading spaces and tabs present on every non-blank line. Once it is found, it is sliced from the front of each line, so deeper indentation survives unchanged.
What to Expect
Best for
- pasting code that arrived indented
- levelling a list before comparing it
What this tool keeps
- the dedented block and the prefix length
Sample input
four spaces before each of a and b
Sample output
Removed 4 leading character(s) of common indent. a b
Frequently asked questions
How do I use the dedent list page?
Paste the indented block, then press Run. The first output line reports the prefix that was removed.
Is anything uploaded?
No. The whole calculation runs in this tab with JavaScript: no request is made, no account is needed, nothing is stored, and the page keeps working offline once it has loaded.
What are its limits or bounds?
At least one non-blank line must be present and the lines must share some leading whitespace. With no shared prefix there is nothing to dedent, so the page must refuse rather than trim.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.