Add Leading Spaces

Indent every line with spaces, tabs, or a custom prefix.

Add Leading Spaces Online

This tool adds indentation to the start of every line of your text.
Choose from spaces, tabs, or a custom prefix, set how many, and the result updates instantly.
Paste or type your text in the "Input" field, adjust the settings, and the indented result appears in the "Output" field.


Load an example

Or drop a text file here
Settings
Add a number of ordinary spaces to the front of each line.
Add one or more tab characters to the front of each line.
Add any text you choose, for example "> " or "- ", to the front of each line.

How many spaces or tabs to add to each line (0–100).

When on, blank lines are left untouched.
When on, the new indent is added in front of any indentation the line already has.
When on, spaces or tabs at the end of each line are removed.
0 lines  |  0 chars
Ready to add leading spaces.


Overview

The "Add Leading Spaces" tool inserts indentation into the left edge of every line in your text. Leading spaces are the blank characters that appear before the first visible character of a line. By adding them in bulk, you can shift a whole block of text to the right in one action.

This is useful any time a block of text needs a uniform margin. Developers use it to indent code snippets so they fit neatly inside a documentation page or a forum post. Writers use it to turn plain paragraphs into nested list items or stepping-blockquote replies. Because the result updates live as you type or change the settings, you can see the indentation grow and shrink before you commit to it.

The original input stays untouched in the "Input" field while the indented result is written to the "Output" field, ready to copy or download. The tool is free, requires no account, and runs entirely in your browser.


How to Use This Tool

1. Add your text: Paste or type it into the "Input" field, click "Upload a file" to load a text file, or drop a file onto the dashed zone. Use "Load an example" to try a sample.

2. Choose an indent type: Pick Space (the default), Tab, or Custom, then set the repeat count or custom text. The result updates instantly.

3. Tune the options: Use Skip empty lines, Preserve existing indent, and Trim trailing whitespace to control exactly which lines change and how.

4. Copy or download: The result appears in the "Output" field. Copy it to the clipboard or download it as a file, and use "Clear & Reset" to start over.


Examples

1. Indent a code snippet

Add 4 spaces to every line to nest a snippet inside a document.

Input
def add(a, b):
    return a + b

print(add(2, 3))
Output
    def add(a, b):
        return a + b

    print(add(2, 3))

2. Build a nested list

Add "- " as a custom prefix to turn plain lines into a bulleted list.

Input
Draft the outline
Research the sources
Write the first edit
Output
- Draft the outline
- Research the sources
- Write the first edit

3. Mark up an email reply

Add "> " as a custom prefix to turn quoted lines into a reply.

Input
Thanks for the update.
Let us know when the report is ready.
See you at the meeting.
Output
> Thanks for the update.
> Let us know when the report is ready.
> See you at the meeting.

4. Skip empty lines

Add 2 tabs to the non-empty lines and leave the blank line alone.

Input
Header row

Second row

Third row
Output
		Header row

		Second row

		Third row

Features & Options

Input & Output: Type, paste, upload, or drop your text into the "Input" field. The indented result is written to the "Output" field, ready to copy or download.

Space: Adds a chosen number of ordinary spaces to the front of each line. For example, 3 spaces:

   alpha
   beta
   gamma

Tab: Adds one or more tab characters to the front of each line. Tabs are the usual choice for indenting code because they are easy to remove and to align. Two tabs on these lines:

		alpha
		beta
		gamma

Custom: Adds any exact text you choose to the front of each line. Use "- " for a bulleted list, "> " for an email quote, or "• " for a simple bullet dot. For example, "> ":

> alpha
> beta
> gamma

Repeat count: (Space and Tab only) Sets how many spaces or tabs to add, from 0 to 100. A setting of 0 leaves the line unchanged.

Skip empty lines: When on (off by default), blank lines and whitespace-only lines are left untouched. Input:

alpha

beta

With Skip empty lines on:

  alpha

  beta

Preserve existing indent: When off (the default), the new indent is added after any leading spaces or tabs the line already has are removed, so the existing indentation is replaced. When on, the new indent is added in front of whatever indentation the line already has, stacking the two. For example, adding 2 spaces to a line that already starts with 4:

    alpha

With Preserve existing indent off:

  alpha

With Preserve existing indent on:

      alpha

Trim trailing whitespace: When on, spaces or tabs at the end of each line are removed before the new indent is added. This cleans up the ragged right edge that often appears when text is copied from a document.

Load an example: Loads a sample text with pre-configured settings so you can see the tool in action immediately.

Copy & Download: "Copy" puts the output on your clipboard; "Download" saves it as a text file.


FAQs

FAQ 1: What is the difference between spaces and tabs?
Answer: A space is a fixed-width blank character, while a tab is a variable-width one that jumps to the next tab stop. Spaces are more portable across editors, so they are safer for documents; tabs are more compact and easier to align in code.

FAQ 2: Can I indent just part of my text?
Answer: The tool indents every non-empty line in the input. To indent only some lines, paste just those lines into the input field and process them separately.

FAQ 3: What does "Preserve existing indent" do?
Answer: It decides whether the new indentation is added on top of indentation the line already has. Turn it on to stack the two, or leave it off to replace the existing leading spaces and tabs with the new indent.

FAQ 4: Does the tool modify my original text?
Answer: No. The "Input" field is never modified. Only the copy in the "Output" field reflects the indentation you added.

FAQ 5: Will blank lines in my text be indented?
Answer: By default the "Skip empty lines" switch is off, so blank lines are indented too. Turn the switch on to leave blank lines exactly as they are.

FAQ 6: Is my text private?
Answer: Yes. The tool runs entirely in your browser with JavaScript. Your text is never uploaded to or stored on our servers.


Tools Worth Trying

TextToolz

The Ultimate Text Tools

TextToolz works seamlessly to let you convert and design your text. It is fast, reliable and secure. Trusted by thousands of users.