Convert Tabs to Spaces
Input
Number of spaces per tab:
How to use Convert Tabs to Spaces
- 1
Paste your text
Paste code or text that contains tab characters into the input box.
- 2
Set spaces per tab
Choose how many spaces each tab should become using the 'Number of spaces per tab' field, such as 2 or 4.
- 3
Convert the tabs
Click 'Convert Tabs to Spaces' and every tab is replaced by your chosen number of spaces.
- 4
Copy the output
Use 'Copy Output' to grab the cleaned, space-indented text for your editor or document.
Frequently asked questions
How many spaces does each tab get converted to?
You decide. Enter any value in the 'Number of spaces per tab' field, then each tab character in your text is replaced by exactly that many spaces.
Why convert tabs to spaces in code?
Many style guides and linters require spaces for consistent indentation, since tabs can render at different widths in different editors. Converting to spaces guarantees your code looks the same everywhere.
Does it only replace leading indentation or all tabs?
It replaces every tab character in the text, including tabs that appear in the middle of a line, not just the indentation at the start of each line.
Will it change my line breaks or other whitespace?
No. Only tab characters are replaced. Your line breaks, existing spaces, and the rest of the content stay exactly as they were.
Is it free and is my code uploaded anywhere?
The tool is free with no sign-up, and the conversion runs entirely in your browser, so your code or text is never sent to a server.
Related tools
Keep going with these handy tools