Text tools

Indent text: add, remove or convert leading spaces and tabs

This text indenter puts spaces or tabs at the start of every line in one step. It can also take indentation off, strip it completely or convert leading tabs to spaces and back. Paste text or open a UTF-8 file, choose an Operation and select Apply indentation. It runs in your browser.

Processed in your browser

Indentation options

Prefix each included line with Count spaces or literal tabs. Existing indentation stays after them.

Editor results use LF for CRLF, CR and Unicode line and paragraph separators. Downloads use UTF-8; no rich formatting is retained.

Choose your options, then apply indentation.

Result

How to indent text

To indent text, paste it into Input text, keep Add indent and select Apply indentation. The Result box shows the new text, and its heading shows how many lines changed and the size of the result.

  1. Type, paste or open text

    Fill Input text, select Open UTF-8 file or try Use example. File contents appear after you apply.

  2. Choose the indent change

    Choose an Operation and Spaces or Tabs under Unit. Add and Remove use Count; Normalize uses Tab width. Tick Include blank lines to change empty lines too.

  3. Apply and save the text

    Select Apply indentation. Check the changed-line count and result size, then Copy or Download .txt. Use as input starts another pass.

Applying again starts from the same input. Changing the text or any option clears the old result. Cancel stops a run and keeps your input. Reset clears the text and the file and sets the options back to Add indent, Spaces, Count 2 and Tab width 4.

What each operation does

Add indent puts Count spaces or tabs in front of each line, and any indentation a line already has stays after them. A line that starts with two spaces has four after you add two.

Remove indent deletes up to Count of the chosen character from the start of each line and stops at the first different character. Removing 4 spaces from a block of code keeps its nesting: a line indented by 8 spaces ends up with 4, and a line indented by 4 ends up at the margin. Strip leading indent removes every leading space and tab.

Normalize indent rewrites the indentation in one unit and keeps its width. A tab moves to the next multiple of Tab width, which starts at 4. At width 4, a space followed by a tab becomes four spaces, or one tab when Unit is Tabs. Six spaces become one tab and two spaces, since a part smaller than one tab stays as spaces.

The editors display tabs at width 4, except while Normalize indent is selected. Then they use the Tab width you set.

Blank lines, line endings and files

Blank lines stay as they are by default. A blank line is empty or holds only spaces and tabs. Tick Include blank lines to indent or strip those lines as well. A line break at the very end of the text does not create an extra line to indent. Empty input gives an empty result.

Text you type or paste into the editor uses LF line breaks after processing. CRLF, CR, and Unicode line and paragraph separators become LF. Open UTF-8 file keeps the file's own endings in the download: Download .txt keeps every CRLF, LF and CR, the Unicode line and paragraph separators, and a leading byte order mark, which stays before the first line's indentation. Both boxes display those line breaks as LF. Use as input moves the displayed result into Input text with LF breaks. The file must be valid UTF-8 whatever its name or type.

Copy keeps the processed text's line endings. The app you paste into may change them.

Limits

The tool changes only spaces and tabs at the start of a line. Nonbreaking spaces, other Unicode spaces and the spaces inside or at the end of a line stay as they are, and so do letters, emoji and accents. It does not read code, so it cannot fix indentation that is wrong for a language, and it does not reformat JSON, XML or HTML. Every included line gets the same change.

There is no set text-size or indent-size limit. Count must be a whole number from zero up, and Tab width must be a whole number from one up. Both must be numbers your browser can represent exactly. Your browser's memory limits the result; the tool shows an error when it does not fit. It needs JavaScript and Web Workers. Rich formatting, such as bold text or a word processor's paragraph indent, is not kept, because both boxes hold plain text.

Questions

What does it mean to indent text?

To indent text is to move a line to the right by putting spaces or tabs before its first character. In plain text, code and Markdown, the indent is made of those characters, so it stays when you paste or save the text. This tool adds, removes or converts them at the start of every line.

What is a quick way to indent text?

Paste all of it into Input text, keep Add indent and select Apply indentation. Every line moves right by the Count you set, 2 spaces unless you change it, in one step. Choose Tabs under Unit for tab indents, and tick Include blank lines if the empty lines should get the indent too.

How do I unindent multiple lines?

Choose Remove indent, pick the character your lines start with and set Count to one level, such as 4 spaces. Each line loses up to that many, so nested lines keep their relative indent. Lines that start with the other character are left alone. Strip leading indent removes all leading spaces and tabs instead.

Is a tab equal to 4 spaces?

Not always. A tab moves text to the next tab stop, so its width depends on where it starts. With Tab width 4, a tab at the start of a line fills 4 columns, and a tab after one space fills 3. Normalize indent converts with this rule, so the lines match in an editor set to that tab width.

Why does the result say no changes?

The tool counts each line whose indentation it changed. For nonempty output, when none changed, for example when you remove spaces from lines that start with tabs or add a Count of 0, the status reads Complete. No changes: the output matches your input. Blank lines left alone by default do not count as changed. Empty output is labelled Empty result.

Is my text uploaded?

No. The text and any file you open are processed in a Web Worker in your browser and are not sent to a server or saved in browser storage. Copy writes to your clipboard and Download .txt saves a file only when you select them. Leaving the page clears the input and the result.