Text & Writing Tools

Unindent Text Online – Remove Indentation from Text and Code

Paste indented text or code and take the indentation away. Set the indent size to remove a fixed amount from the start of each line, or turn on the remove all option to clear the indentation completely. Then copy the result or download it as a .txt file. It runs in your browser page, so there is nothing to install.

0 characters

Options

Processing runs in this page using JavaScript. Do not paste confidential information.

Why use this tool?

Why use this tool?

Text and code often come with more indentation than you want: a snippet copied from inside a nested block, a quote from an email, a list from a document, or a piece of code pasted from a file. Deleting the spaces at the start of each line by hand takes time and is easy to get wrong. An unindent tool does it for every line at once, so the text lines up again.

How to use it

How to use it

  1. Step 1

    Add your text

    Paste or type your indented text into the Input text box, or press Load example to try sample text.
  2. Step 2

    Set the indent size

    Enter how much indentation to remove from each line. The default is 2.
  3. Step 3

    Choose remove all if needed

    Turn on remove all to clear all the indentation from the start of every line.
  4. Step 4

    Check the result

    Read the unindented text in the Result box.
  5. Step 5

    Copy or download

    Press Copy result, or Download .txt to save the file. Press Clear to start again.

How to remove indentation from text online

Paste your indented text into the Input text box. The tool removes the indentation from the start of the lines and shows the result in the Result box. By default it uses an indent size of 2. Change the indent size if your text is indented by a different amount, or turn on remove all to clear the indentation fully.

Copyable sample text

Paste this into the input box, or press Load example: function hello() { return 1; } With the default indent size of 2, the result is: function hello() { return 1; } With remove all turned on, the result is: function hello() { return 1; }

Indent size option

The indent size sets how much indentation is taken from the start of each line. The default is 2. Use a bigger number when your text is indented deeper, and a smaller one when you want to remove just one level.

Remove all option

Remove all is off by default. Turn it on when you want to clear all the indentation from the start of every line, no matter how deep it is. This is useful when you do not know the indent size or when the lines are indented by different amounts.

Copy the result or download it as a .txt file

Use Copy result to put the unindented text on your clipboard (the button shows Copied! when it works). Use Download .txt to save the result as a plain text file. Clear empties the tool so you can start again.

Features explained

Unindent text online

Removes indentation from the start of the lines in your text.

Indent size option

Sets how much indentation is removed from each line. The default is 2.

Remove all option

Off by default. When on, it clears all the indentation instead of removing a set amount.

Copy result to clipboard

One click copies the result. The button changes to Copied! so you know it worked.

Download as .txt

Saves the result as a plain text file, useful when you want to keep it.

Load example

Fills the input with sample text so you can see how the options work before you use your own.

Clear and reset

The Clear button empties the tool so you can start with new text.

Runs in the page

Text is processed with JavaScript in the page. No request to a server was found in the tool code.

What can you use it for?

Clean up pasted code

Remove the extra indentation from a code snippet you copied out of a nested block.

Fix indented text copied from emails and documents

Take the leading indent away from quoted or indented text so it lines up with the rest of your document.

Prepare text for a form or a markdown file

Remove the indentation before you paste text into a place where leading spaces cause problems.

Tidy notes and lists

Clear the indentation from notes or lists that were copied with extra spaces at the start of each line.

Share clean snippets

Unindent a code or text example before you post it in a chat, a ticket or a document.

Tool information

Tool typeUnindent text (remove indentation from lines)
InputPlain text, pasted or typed in the Input text box
Indent size (default)2
Remove all (default)Off
OutputThe unindented text in the Result box
CopyCopy result button
Download format.txt (plain text)
ProcessingIn the page with JavaScript (client-side)

Benefits

  • Saves time compared with deleting leading spaces line by line.
  • Two options: remove a set indent size, or clear all the indentation.
  • Handy for pasted code and copied text.
  • Copy or download the result in one click.
  • Works in the browser page, with nothing to install.

Limitations

  • It works with plain text. The code shows no file upload, so paste your text into the box.
  • It is made to change the start of the lines. It does not edit the words in your text.
  • It has two options only: indent size and remove all.
  • Check the result if your text mixes tabs and spaces, because the tool code does not say how each is handled.
  • The download is a .txt file only.

Privacy

This tool processes your text in the page using JavaScript, and no network request was found in the tool code. Even so, do not paste confidential information such as passwords or private data.

Tips

  • Use Load example first to see how the result looks.
  • If your lines are indented by different amounts, turn on remove all.
  • If you want to remove just one level of indentation, set the indent size to the size of one level.
  • Press Clear before you paste new text so old text does not stay in the tool.

Frequently asked questions

How do I remove indentation from text online?

Paste your text into the Input text box. The tool removes the indentation from the start of the lines, and the result appears in the Result box.

How do I unindent code?

Paste your code into the input box and set the indent size to the amount you want to remove. The default is 2. Turn on remove all to clear all the indentation.

How do I remove all the leading spaces from every line?

Turn on the remove all option. It is off by default.

What is the indent size?

It is the amount of indentation the tool removes from each line. The default is 2.

What does the remove all option do?

It clears all the indentation from the start of the lines, instead of removing only the amount set in the indent size.

Can I copy or download the result?

Yes. Press Copy result to copy it, or Download .txt to save it as a plain text file.

Is my text uploaded to a server?

The tool processes text in the page with JavaScript, and no network request was found in the tool code. Still, avoid pasting confidential information.

Does this tool change the words in my text?

No. It is made to remove indentation from the start of the lines, not to edit the words.