How to replace tabs with spaces
Sample text with tabs you can copy and try
What the spaces per tab option does
How the conversion works
Convert tabs to spaces and download as a .txt file
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
| Processing | In your browser (client-side JavaScript) |
|---|---|
| Input | Plain text typed or pasted into the Input text box |
| What changes | Only tab characters. Each tab becomes the same number of spaces |
| Default spaces per tab | 4 |
| Allowed range | 1 to 32 spaces per tab |
| Output actions | Copy result, Download .txt |
| Download format | .txt (plain text) |
| Extra buttons | Load 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.