Text Indenter
Add or remove indentation from every line of a block, with spaces or tabs and a configurable width.
Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.
What the Text Indenter does
Use this text indenter to add or remove indentation from every line of a block, with spaces or tabs and a configurable width. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for indenting a code block for a Markdown document. There are more free online tools on FreeToolStation.org.
How to use it
- Paste the text or code block.
- Choose whether to add, remove one level, or strip all leading whitespace.
- Set the width and whether to use tabs.
- Copy the result.
How it works
Adding a uniform indent to every line is most often needed for pasting a block into a document, a quoted email, a YAML value or a Markdown code block — all contexts where the surrounding structure requires a specific leading offset.
Blank lines are left alone rather than being given trailing whitespace, which is the convention every linter expects and the thing most naive indenters get wrong.
Tabs and spaces are not interchangeable in every context. Makefiles require a literal tab for recipe lines and will fail with spaces. Python forbids mixing the two within a block. YAML forbids tabs for indentation entirely. Pick the one the format requires rather than the one you prefer.
When to use it
- Indenting a code block for a Markdown document.
- Adjusting a block before pasting into a YAML file.
- Stripping inconsistent indentation before reformatting.
- Removing one level of nesting from a block.
Common mistakes to avoid
- Using spaces where a tab is required, as in a Makefile recipe line.
- Using tabs in YAML, which forbids them for indentation.
- Mixing tabs and spaces in Python, which is a syntax error.
Frequently asked questions
How do I indent a whole block of text?
Paste it in, pick "Add indentation" and set the width. Every non-blank line gets the prefix.
Are blank lines indented?
No. They are left empty rather than given trailing whitespace, which is what linters expect.
Should I use tabs or spaces?
Whatever the format requires. Makefiles need tabs, YAML forbids them, and Python forbids mixing. Preference only comes into it where the format allows both.