Convert Four Spaces to Tab
Swap four-space indentation for tab characters in seconds. Paste your code or text and get clean tab-indented output instantly — no server, no signup.
Text with four-space indentation
Paste code or text that uses four spaces per indent level.
Every group of four spaces becomes one tab. Leftover 1–3 spaces and existing tabs are left untouched. Everything runs locally in your browser — nothing is uploaded.
Tab-indented outputYour text with four-space groups replaced by tab characters.
Even large files convert in well under 100ms in modern browsers.
How to convert four spaces to tabs
Convert in 3 steps
Takes ~5 seconds- 1Paste your text
Add any code or text that uses four-space indentation into the input box.
- 2Click Convert to Tabs
The tool replaces every group of four spaces with a single tab character.
- 3Copy the output
Copy or download the tab-indented result and paste it into your editor or file.
Who should use this tool?
- Developers migrating codebases from space-based to tab-based indentation style guides
- Engineers normalizing log files or config snippets before parsing or diffing
- Teams converting pasted code snippets to match a tab-indented project standard
Examples
A single four-space indent becomes one tab.
return true;
return true;
Eight spaces (two indent levels) become two tabs.
console.log(x);
console.log(x);
Five spaces: one tab plus one leftover space.
hello
hello
Convert four-space indentation to tabs
This tool reverses the common four-spaces-per-tab convention. Paste any indented text and every group of four consecutive spaces is swapped for a tab character. Partial groups of one to three spaces and any existing tab characters are left exactly as they are.
Use this four spaces to tab converter to reformat code or plain text that uses four-space indentation into tab-indented output. The tool replaces each group of four consecutive spaces with a single tab, handling multiples like eight or twelve spaces correctly. It is the reverse of the convert tab to four spaces tool, and all processing runs locally in your browser for fast, private conversion.
Converts every run of four spaces — not just leading indentation — and handles multiples correctly.
- Eight spaces → two tabs
- Leftover 1–3 spaces preserved
- Existing tabs untouched
Handles code, logs, config files, and any plain-text content with four-space indentation.
- Multi-line support
- Any programming language
- Line breaks preserved
All conversion runs in your browser. No data is ever sent to a server.
- No upload required
- Works offline
- No signup needed
Conversion tips
Get consistent results by preparing your input before converting.
- Remove mixed indentation (tabs and spaces on the same line) before converting to avoid unexpected output.
- Run a diff after converting to confirm no unintended whitespace changes crept in.
- Configure your editor to display tabs at four-space width so the converted file looks identical visually.
Frequently asked questions
What happens to a run of five, six, or seven spaces?>
Will existing tab characters in my file be changed or doubled?>
How is this different from Convert Tab to Four Spaces?>
Does the converter only affect leading indentation, or inline spaces too?>
Related String tools
Wrap each line of text in square brackets. Paste a list and get bracketed output instantly. Works fast in your browser.
Wrap each line of text in double quotes. Paste a list and get quoted output instantly. Use it in your browser for quick, copy-ready results.
Add line numbers to each line of text with selectable separators. Choose no separator, a period, or a closing parenthesis.
Add a custom prefix to every line in your text. Enter a prefix once and apply it to all lines instantly. In your browser.
Add a custom suffix to every line in your text. Enter a suffix once and apply it to all lines instantly. In your browser.
Wrap each line of text in parentheses. Paste a list and get parenthesized output instantly. Works fast in your browser.
Wrap each line of text in single quotes. Paste a list and get quoted output instantly. Use it in your browser for quick, copy-ready results.
Calculate average sentence length instantly. Paste text and get the mean words per sentence in one click. In your browser.
Calculate average word length instantly. Paste text and get the mean characters per word in one click. In your browser.
Calculate the total UTF-8 byte size of your text instantly. Paste content and get an exact byte count in one click.
Replace tab characters with four spaces. Clean up pasted text and align indentation instantly. Works fast in your browser.
Replace tab characters with a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.
Count the number of lines in a text block. Paste your text and get the line count instantly. Works fast in your browser.
Remove empty lines from text. Paste your text and get a cleaner block instantly. Use it in your browser for quick, copy-ready results.
Estimate how long text will take to read. Set words per minute and get instant reading time. Works fast in your browser.
Find the longest line in a text block. Paste your text and get the longest line instantly. Works fast in your browser.
Find the shortest line in a text block. Paste your text and get the shortest line instantly. Works fast in your browser.
Convert dot-separated names like john.doe into Last, First format with proper Title Case. Paste a list and get results instantly.
Prepend a dollar sign to each line of numbers. Format currency values instantly. Use it in your browser for quick, copy-ready results.
Count the total number of paragraphs in your text instantly. Paste content and get an exact paragraph count in one click.
Strip dollar signs from currency values. Paste your list and get clean numbers instantly. Use it in your browser for quick, copy-ready results.
Collapse multiple spaces into a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.
Count the total number of sentences in your text instantly. Paste content and get an exact sentence count in one click.
Convert text to lowercase instantly. Paste your text and get lowercase output in seconds. Use it in your browser for quick, copy-ready results.
Convert text to uppercase instantly. Paste your text and get uppercase output in seconds. Use it in your browser for quick, copy-ready results.
Invert the case of every letter. Lowercase becomes uppercase and uppercase becomes lowercase. Works fast in your browser.
Calculate the total character length of your text instantly. Paste any text and get an exact count in one click.
Reverse text line by line. Paste your content and get reversed output instantly. Use it in your browser for quick, copy-ready results.
Estimate AI token count instantly from your text input. Paste content and get a quick token estimate for prompt planning.
Trim each line to a maximum character length. Set a line length count and truncate all lines instantly. In your browser.
Trim each line to a maximum number of words. Set a word count and truncate all lines instantly. Works fast in your browser.
Count unique words in your text instantly. Paste content and get an exact unique word total in one click. In your browser.
Count the total number of words in your text instantly. Paste any content and get an exact word count in one click.