Unindent Text

Remove indentation from each line.

Input
Indentation Mode
Delete all indentation symbols from the beginning of each line.
Delete a certain amount of indents from the beginning of each line.
Indentation Symbols
Which indentation symbols to remove?
Use "\t" to remove tabs.
Multiline Mode
Remove indent characters from each text line or paragraph.
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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

Input
line one
line two
Output
  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.

Understanding Indentation: Why It Accumulates and How to Remove It Cleanly Indentation is one of the most fundamental organizational tools in both programming and structured writing. In code, it communicates hierarchy — a line indented further than the one above it belongs inside a block, a function, or a class. In plain text and markup formats like Markdown or YAML, indentation similarly signals nesting and structure. This visual hierarchy is enormously useful when you're reading content in its original context. The problem begins the moment you move that content somewhere else. When you copy a method from inside a class, that method's body carries the full accumulated indentation from every level it was nested within. A method inside a class inside a module might carry three levels of indentation before a single line of actual logic. Paste that into a README, a Slack message, a documentation site, or a code review comment, and it looks strange — every line pushed far to the right, forcing the reader to mentally subtract the extra whitespace to understand the actual structure. The same problem appears constantly with configuration files. A database block nested inside an environments block inside a top-level config file carries two or three indent levels. Extract just the database block for use as a standalone example in documentation, and it arrives pre-indented, looking like it belongs inside something that isn't there. How Unindent Works The standard approach to unindenting — used by most editors and dedicated tools alike — is to calculate the minimum indentation level across all non-empty lines. This is the largest amount of leading whitespace that can be removed from every line simultaneously without making any line's indentation go negative. Once that baseline is established, it's subtracted from the start of every line. Empty lines are typically excluded from the calculation because they often contain zero characters of indentation, which would incorrectly force the minimum to zero and produce no change at all. The result is that the content's internal structure — the relative indentation between lines — is completely preserved. A for loop inside a function that was indented three levels from the left margin will still appear indented one level relative to the function keyword; the function itself just now starts at column zero instead of column twelve. Unindent vs. Related Text Operations It's worth distinguishing unindent from a few related operations that are often confused with it. Removing all whitespace strips every space and tab from every line — useful for data normalization but destructive to code structure. Trimming removes leading and trailing whitespace from each line independently, which is different from unindent: trim would bring every single line to column zero, destroying relative indentation entirely. Dedent — the term used in Python's textwrap.dedent() and in many editors — is essentially a synonym for what this tool does: remove the common leading whitespace prefix while preserving relative structure. In editors, unindent is usually triggered with Shift+Tab or a dedicated keyboard shortcut, and it decrements indentation by one level at a time. A dedicated tool like this one is more useful when you need to remove multiple levels at once or when you're working outside an editor environment — in a browser, in a documentation workflow, or in a script. For developers, understanding this distinction makes the tool far more useful: it's not a destructive operation that flattens your code. It's a precise, structure-preserving transformation that simply relocates your content's leftmost column to position zero.

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.