Overview
Introduction
Nesting a block of code, quoting a paragraph, or formatting a list often means adding the same prefix to every single line.
Doing that by hand in a text editor, line by line, is tedious for anything longer than a few lines.
What Is Text Indenter?
An indenter that prepends a chosen indent unit, repeated a chosen number of times, to the start of every line in a block of text.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How Text Indenter Works
The tool builds a prefix by repeating the indent unit the given number of levels, splits the input on newlines, prepends the prefix to each line, and rejoins them.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use Text Indenter
Use it to nest a block of code inside another block, quote a paragraph with a leading marker, or indent a list for a markdown document.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside Text Dedenter, String Left Aligner and Word Wrapper.
Features
Advantages
- Works with any indent unit, spaces, tabs, or a custom marker like '> '.
- Supports multiple indent levels in one pass.
- Builds the prefix once and reuses it for every line, so the work stays proportional to the line count rather than to lines multiplied by indent depth.
Limitations
- Applies the same indent to every line uniformly; it can't detect and preserve existing relative indentation structure.
- Indents blank lines as well, leaving trailing whitespace on lines that were previously empty.
Examples
Best Practices & Notes
Best Practices
- Use '> ' as the indent unit to quickly quote a paragraph in markdown or email-style plain text.
- Match the indent unit to the surrounding file's existing convention, since mixing tabs into a space-indented file shows up as misalignment in most editors.
- Indent code blocks before pasting them into markdown, where a four-space prefix is what marks a block as preformatted.
Developer Notes
The prefix is computed once as `indentUnit.repeat(levels)` and then prepended to each line from `input.split("\n")`, so the repetition cost is paid once rather than per line.
Text Indenter Use Cases
- Nesting a code snippet one level deeper before pasting it into a larger file
- Quoting a paragraph of email or chat text with a leading marker
- Indenting a list block for a markdown document
Common Mistakes
- Mixing tabs and spaces as the indent unit across separate passes, which can produce inconsistent-looking indentation in an editor.
- Overlooking that blank lines pick up the prefix too, which many linters then flag as trailing whitespace.
Tips
- Set levels higher than 1 to indent multiple nesting depths in a single pass instead of running the tool repeatedly.
- Splitting is on the newline character alone, so text with Windows line endings keeps its carriage returns and still indents correctly.