Text & Writing Tools

Convert Tabs to Spaces Online

Paste your text, choose how many spaces each tab should become, and get the result right away. Copy it with one click or download it as a .txt file. Only the tab characters change. The rest of your text stays as it is.

0 characters

Options

Processing runs in this page using JavaScript. Do not paste confidential text on a computer you do not trust.

Why use this tool?

Why use this tool?

Tabs and spaces look the same in some editors and very different in others. Code, config files, notes and pasted text often mix the two, which can make indentation look broken. This tool replaces every tab with the same number of spaces in one step, so you do not have to fix each line by hand.

How to use it

How to use it

  1. Step 1

    Add your text

    Type or paste your text into the Input text box, or press Load example.
  2. Step 2

    Set spaces per tab

    Under Options, enter how many spaces should replace each tab. The default is 4.
  3. Step 3

    Check the result

    Read the converted text in the Result box.
  4. Step 4

    Copy or download

    Press Copy result to copy the text, or Download .txt to save it as a file.
  5. Step 5

    Start again if needed

    Press Clear to empty the tool and convert something new.

How to replace tabs with spaces

Type or paste your text into the Input text box. Under Options, set the number of spaces per tab. The default is 4. The Result box shows your text with every tab replaced by that many spaces. Then press Copy result, or Download .txt to save it as a file.

Sample text with tabs you can copy and try

Paste this into the Input text box. The indented lines start with tab characters: function greet() { const name = "World"; if (name) { console.log("Hello, " + name); } } With the default setting of 4, each tab becomes 4 spaces, so the second level of indentation becomes 8 spaces. You can also press Load example to fill the box with a ready-made sample.

What the spaces per tab option does

Spaces per tab is the number of spaces that replaces each tab character. The default is 4. The value is kept between 1 and 32, so a number below 1 is treated as 1 and a number above 32 is treated as 32. Use 2 for tighter indentation or 8 for wider indentation.

How the conversion works

The tool finds every tab character and replaces it with the same fixed number of spaces. It does not line text up to tab stops, so a tab in the middle of a line also becomes the full number of spaces. Letters, numbers, line breaks and existing spaces are not changed.

Convert tabs to spaces and download as a .txt file

When the result looks right, press Download .txt to save it as a plain text file. This is useful for longer text that you want to keep or open in another editor.

Features explained

Spaces per tab

Choose how many spaces replace each tab. The default is 4, and the value is kept between 1 and 32.

Replaces every tab

Every tab character in your text is replaced, from the first line to the last.

Copy result

Copies the converted text to your clipboard. The button changes to Copied! when it works.

Download .txt

Saves the result as a plain text file you can open in any editor.

Load example

Fills the Input text box with sample text so you can see how the tool works first.

Clear

Resets the tool so you can start again with new text.

Works in your browser

Text is processed on the page with JavaScript. The tool's code has no step that sends your text to an API.

What can you use it for?

Cleaning up code indentation

Replace tabs with spaces in a code snippet before you paste it into a file or editor that uses spaces.

Config and data files

Some formats, such as YAML, expect spaces for indentation. Convert tabs before you save the file.

Pasting into forms and chats

Tabs can look different from one app to another. Spaces look the same everywhere.

Notes and documents

Fix text copied from a spreadsheet, email or document where tabs show up as large gaps.

Matching a team style

Convert tabs to 2, 4 or 8 spaces to match the style your team or project uses.

Tool information

ProcessingIn your browser (client-side JavaScript)
InputPlain text typed or pasted into the Input text box
What changesOnly tab characters. Each tab becomes the same number of spaces
Default spaces per tab4
Allowed range1 to 32 spaces per tab
Output actionsCopy result, Download .txt
Download format.txt (plain text)
Extra buttonsLoad example, Clear

Benefits

  • Replace every tab in one step instead of fixing lines by hand
  • Pick 2, 4, 8 or any number from 1 to 32 spaces per tab
  • Everything except tabs stays exactly as you wrote it
  • Copy the result or save it as a .txt file

Limitations

  • Every tab becomes the same fixed number of spaces. The tool does not line text up to tab stops, so columns made with tabs may not line up afterwards.
  • Spaces per tab is kept between 1 and 32.
  • It works with plain text typed or pasted into the box.
  • Download is available only as a .txt file.
  • The tool changes tabs only. It does not fix other spacing problems, such as extra spaces or blank lines.

Your text stays in your browser

This tool processes your text on the page using JavaScript. The tool's code does not send your text to a server or API. Even so, avoid pasting passwords or other confidential text on a shared or untrusted computer.

Tips

  • Use the same spaces per tab value your project or team already uses, often 2 or 4.
  • Look at the Result box before you paste the text back into your project.
  • If your text uses tabs to make columns, check that the result still looks right.
  • Press Load example to see how the tool works before using your own text.
  • Copy anything important before you press Clear.

Frequently asked questions

How do I convert tabs to spaces online?

Paste your text in the Input text box, set the spaces per tab under Options, and read the converted text in the Result box. Then copy it or download it.

How many spaces does each tab become?

The default is 4 spaces per tab. You can change it to any number from 1 to 32.

What happens if I enter a number below 1 or above 32?

The value is kept between 1 and 32. A number below 1 is treated as 1, and a number above 32 is treated as 32.

Does the tool line text up to tab stops?

No. Every tab is replaced by the same fixed number of spaces, wherever it appears in the line.

Does it change anything besides tabs?

No. Only tab characters are replaced. Letters, numbers, existing spaces and line breaks stay as they are.

How do I copy the converted text?

Press Copy result. The button changes to Copied! when the text is on your clipboard.

Can I download the result as a file?

Yes. Press Download .txt to save the result as a plain text file.

Is my text uploaded to a server?

The tool processes text on the page with JavaScript, and its code does not send your text to an API. Still, do not paste confidential text on a computer you do not trust.