Text

Text Indent Tool

Add or remove indentation, convert tabs to spaces and back, detect the existing indent style, strip common leading whitespace and apply quote or comment prefixes.

Last reviewed by the Radiatus Cloud team

Result appears here.

Need this done properly for your business?

Radiatus delivers secure cloud, DevOps & compliance engineering.

Book a free consult

Mixed tabs and spaces is a real bug, not a style argument

Whether a file uses tabs or spaces is a preference. Whether it uses both is not. A file with mixed indentation renders differently depending on the tab width setting of whoever opens it, so code that looks correctly nested to one person looks wrong to another. In Python it is worse than cosmetic: mixed indentation is a syntax error under Python 3, and under Python 2 it silently changed the block structure. Detecting and normalising it is the fix.

Dedenting is the common need

Code copied out of a function arrives indented by the enclosing block, and pasting it into a document or a new file means removing that leading whitespace from every line without disturbing the relative indentation inside it. The rule is to find the smallest leading whitespace across all non blank lines and remove exactly that much from each, which is what the dedent function in most standard libraries does.

Prefixes are indentation too

Quoting an email adds a greater than sign to every line. Commenting out a block adds a comment marker. Markdown code blocks need four spaces. These are the same operation as indenting with a different character, and doing them by hand across dozens of lines is error prone in a way that is immediately visible when one line is missed.

Related tools

  • Emoji Picker & Copier — Browse, search, and copy emojis by category. Collect multiple emojis and copy them all at once. Recently used emojis saved locally.
  • Text to Speech Player — Convert text to natural speech using the Web Speech API. Adjustable voice, speed, pitch, and volume with playback controls.
  • Speech to Text Transcriber — Transcribe speech to text using your microphone. Supports multiple languages with continuous listening, copy, and download features.
  • Instagram Caption Generator — Generate Instagram caption ideas from a topic, tone, and optional CTA. Fast, template-based suggestions.

Frequently Asked Questions

Why is mixing tabs and spaces a problem?

Because the file renders differently depending on the reader tab width, so nesting that looks correct to one person looks wrong to another. In Python it is a syntax error under version 3 and silently changed block structure under version 2.

What does dedent do?

It finds the smallest amount of leading whitespace across all non blank lines and removes exactly that much from each, preserving the relative indentation inside the block. It is what you want after copying code out of a function.

How many spaces should a tab be?

Four is the most common convention and eight is the traditional terminal default, which is why a file indented with tabs can look drastically over indented in some viewers. Go uses tabs by convention, Python style prefers four spaces, and consistency inside one file matters more than the number.

Does this handle blank lines?

Yes. Blank lines are not given trailing indentation, since trailing whitespace on an otherwise empty line shows up as a diff artefact and many linters flag it.

What are prefixes for?

Quoting an email with a greater than sign, commenting out a block with a language comment marker, or indenting a Markdown code block. They are the same operation as indenting with a different character, and doing them by hand across many lines reliably misses one.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Paste text to change its indentation or convert between tabs and spaces.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.