Unindent Text
Remove indentation from each line.
Input
Output
What It Does
The Unindent Text tool removes leading whitespace — spaces and tabs — from the beginning of each line in your text or code. Whether you're working with a deeply nested code block that you've pasted into a new context, or you've copied content from a structured document and need to strip away all that awkward leading padding, this tool handles it instantly. It detects the common indentation level across all non-empty lines and removes it uniformly, preserving the relative indentation between lines so your code structure stays intact. This is especially valuable for developers who regularly copy snippets from indented functions or class methods and need to share them as standalone examples, paste them into documentation, or push them into a format that doesn't support arbitrary indentation. Beyond code, the tool works equally well on plain text, Markdown, configuration files, YAML, TOML, and any other line-based content where you need to strip hierarchical whitespace. Rather than manually selecting and deleting spaces line by line — a tedious and error-prone process — you can paste your content, process it in one click, and copy clean, left-aligned output ready for wherever it needs to go. The tool handles both tab-indented and space-indented content, making it compatible with virtually every code style and editor configuration in common use today.
How It Works
The Unindent Text applies its selected transformation logic to your input and produces output based on the options you choose.
It applies a fixed set of transformation rules to your input, so the output is stable and easy to verify.
All processing happens in your browser, so your input stays on your device during the transformation.
Common Use Cases
- Stripping the extra indentation from a function or method body copied out of a class so it can be used as a standalone snippet in documentation or a README file.
- Cleaning up code pasted from an IDE where auto-indentation added multiple levels of leading spaces that aren't appropriate in the new context.
- Preparing code examples for blog posts, tutorials, or technical articles where flush-left formatting is required by the publishing platform.
- Removing indentation from YAML or TOML configuration blocks that were nested inside a larger config file but now need to stand alone.
- Flattening indented plain-text outlines or hierarchical notes when copying content into an email, chat message, or plain-text field that doesn't render structure visually.
- Normalizing pasted code before running it through a diff tool or linter that is sensitive to unexpected leading whitespace.
- Cleaning up transcript or log output that arrives with inconsistent leading spaces, making it easier to search, parse, or process programmatically.
How to Use
- Paste or type your indented text into the input field. This can be any line-based content: source code, configuration files, plain text, or structured data formats like YAML or TOML.
- The tool analyzes all non-empty lines to determine the minimum common indentation level — the largest amount of leading whitespace that can be safely removed from every line without breaking relative structure.
- Click the process button to apply the unindent operation. Leading whitespace equal to the detected minimum indent level is stripped from the start of every line in the input.
- Review the output in the result field. Lines that previously shared the same base indent level will now start at column zero, while lines that were indented further will retain their relative extra indentation.
- Copy the cleaned output using the copy button and paste it directly into your target destination — a code editor, documentation platform, email, or any other context.
Features
- Automatic minimum-indent detection that calculates the largest safe amount of whitespace to remove without disrupting the relative indentation structure of your content.
- Support for both space-based and tab-based indentation, ensuring compatibility with every common code style, editor setting, and language convention.
- Preservation of relative indentation between lines, so nested blocks and hierarchical structures remain visually intact after the base indent is removed.
- Handles mixed content gracefully, skipping blank lines when calculating the common indent level so they don't interfere with the unindent calculation.
- One-click copy of the processed output for immediate use in editors, documentation tools, emails, or any downstream workflow.
- Works on any line-based text format — source code in any language, Markdown, YAML, TOML, INI files, plain prose, outlines, and log output.
- Processes content entirely in the browser with no data sent to a server, ensuring your code and sensitive configuration content stays private.
Examples
Below is a representative input and output so you can see the transformation clearly.
line one line two
line one line two
Edge Cases
- Very large inputs may take a few seconds to process in the browser. If performance slows, split the input into smaller batches.
- Mixed formatting (tabs, line breaks, or inconsistent delimiters) can affect output. Normalize spacing first if needed.
- Unindent Text follows the selected options strictly. If the output looks unexpected, re-check option settings and input format.
Troubleshooting
- Output looks unchanged: confirm the input contains the pattern this tool modifies and that the correct options are selected.
- Output differs from a previous run: confirm that the input and every option match, because deterministic tools should repeat when the settings are identical.
- Unexpected characters: check for hidden whitespace or encoding issues in the input and try normalizing first.
- Slow processing: reduce input size or try a modern browser with more available memory.
Tips
When copying a method or function body out of a class, the entire block will often carry two or three levels of indentation from its original context. Paste it here first before adding it to documentation or sharing it with a colleague — the output will look intentional and clean rather than awkwardly padded. If your content uses tabs and you're targeting a platform that renders tabs as a fixed number of spaces, consider running it through a tab-to-spaces converter after unindenting to ensure consistent visual alignment everywhere. For YAML files, always double-check the output before using it as a standalone document, since YAML is indentation-sensitive and removing the wrong level of nesting can change the data structure's meaning.
Frequently Asked Questions
What does the Unindent Text tool actually do?
The Unindent Text tool removes the common leading whitespace — spaces or tabs — from the beginning of every line in your input. It calculates the minimum indentation level across all non-empty lines and subtracts that amount from each line uniformly. The result is that the content shifts to the left so the least-indented lines start at column zero, while all relative indentation between lines is preserved exactly as it was.
Will unindenting break my code's structure?
No. The tool preserves relative indentation, which is what actually defines your code's structure. If a for loop was indented two spaces more than the surrounding function body, it will still be indented two spaces more after unindenting — it just won't have the extra shared prefix that came from the original nesting context. The internal hierarchy of your code remains completely intact.
What's the difference between unindent and trim?
Trim removes leading and trailing whitespace from each line independently, bringing every single line to the leftmost column. This would destroy relative indentation and make all lines start at position zero regardless of their original nesting level. Unindent, by contrast, removes only the shared baseline indentation and leaves each line's extra indentation — relative to that baseline — untouched. For code and structured text, unindent is almost always what you want.
Does the tool work with tabs as well as spaces?
Yes. The tool handles both tab-indented and space-indented content. Tabs and spaces are both recognized as indentation characters and are processed correctly. If your content mixes tabs and spaces, results may vary depending on how the tool normalizes mixed indentation, so for best results it's helpful to ensure your indentation style is consistent before processing — something a tab-to-spaces converter can help with.
Why does the output still have some indentation on certain lines?
That's intentional and correct behavior. Lines that were indented more than the minimum level in the original content will still have some indentation in the output — the extra amount beyond the shared baseline. This is the relative indentation that defines your code's or document's structure. Only the common prefix that every non-empty line shared has been removed. If you want every line at column zero regardless of structure, you would need a full trim or strip operation instead.
How is this different from pressing Shift+Tab in a code editor?
In most editors, Shift+Tab decrements indentation by one level (one tab stop or a fixed number of spaces) regardless of the actual indentation amount. To remove three levels of accumulated indentation, you'd need to press Shift+Tab three times. This tool removes however many levels are needed in a single operation, making it much faster when dealing with deeply nested content or when you're working outside an editor environment entirely.