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.

0 lines in0 lines outN/A runtime

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
  1. 1
    Paste your text

    Add any code or text that uses four-space indentation into the input box.

  2. 2
    Click Convert to Tabs

    The tool replaces every group of four spaces with a single tab character.

  3. 3
    Copy the output

    Copy or download the tab-indented result and paste it into your editor or file.

Use the reverse tool — Convert Tab to Four Spaces — to switch back any time.

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.

Input
    return true;
Output
	return true;

Eight spaces (two indent levels) become two tabs.

Input
        console.log(x);
Output
		console.log(x);

Five spaces: one tab plus one leftover space.

Input
     hello
Output
	 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.

Accurate replacement

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
Works on any text

Handles code, logs, config files, and any plain-text content with four-space indentation.

  • Multi-line support
  • Any programming language
  • Line breaks preserved
Private by default

All conversion runs in your browser. No data is ever sent to a server.

  • No upload required
  • Works offline
  • No signup needed
Privacy first: we never send your input to a server. Everything runs locally in your browser.

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?>
The tool converts as many complete four-space groups as possible and leaves the remaining 1–3 spaces as regular spaces. For example, six spaces become one tab followed by two spaces.
Will existing tab characters in my file be changed or doubled?>
No. The tool only targets groups of four consecutive space characters. Any tab characters already present in the input are passed through completely unchanged.
How is this different from Convert Tab to Four Spaces?>
This tool is the reverse operation — it replaces four-space groups with tabs. The Convert Tab to Four Spaces tool does the opposite, replacing each tab character with four space characters.
Does the converter only affect leading indentation, or inline spaces too?>
It replaces every run of four consecutive spaces anywhere in the text, not just at the start of a line. If you have four spaces in the middle of a string literal, those will be converted too, so review the output if your content contains deliberate inline spacing.

Related String tools

Add Brackets Around String

Wrap each line of text in square brackets. Paste a list and get bracketed output instantly. Works fast in your browser.

Add Double Quotes Around String

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 Text

Add line numbers to each line of text with selectable separators. Choose no separator, a period, or a closing parenthesis.

Add Line Prefix to Text

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 Line Suffix to Text

Add a custom suffix to every line in your text. Enter a suffix once and apply it to all lines instantly. In your browser.

Add Parentheses Around String

Wrap each line of text in parentheses. Paste a list and get parenthesized output instantly. Works fast in your browser.

Add Single Quotes Around String

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.

Average Sentence Length Calculator

Calculate average sentence length instantly. Paste text and get the mean words per sentence in one click. In your browser.

Average Word Length Calculator

Calculate average word length instantly. Paste text and get the mean characters per word in one click. In your browser.

Byte Count Calculator

Calculate the total UTF-8 byte size of your text instantly. Paste content and get an exact byte count in one click.

Convert Tab to Four Spaces

Replace tab characters with four spaces. Clean up pasted text and align indentation instantly. Works fast in your browser.

Convert Tab to Single Space

Replace tab characters with a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.

Count Lines in String

Count the number of lines in a text block. Paste your text and get the line count instantly. Works fast in your browser.

Empty Line Remover

Remove empty lines from text. Paste your text and get a cleaner block instantly. Use it in your browser for quick, copy-ready results.

Estimated Reading Time Calculator

Estimate how long text will take to read. Set words per minute and get instant reading time. Works fast in your browser.

Find Longest Line of Text

Find the longest line in a text block. Paste your text and get the longest line instantly. Works fast in your browser.

Find Shortest Line of Text

Find the shortest line in a text block. Paste your text and get the shortest line instantly. Works fast in your browser.

Firstname.Lastname to Last, First

Convert dot-separated names like john.doe into Last, First format with proper Title Case. Paste a list and get results instantly.

Numbers to Dollars

Prepend a dollar sign to each line of numbers. Format currency values instantly. Use it in your browser for quick, copy-ready results.

Paragraph Count Calculator

Count the total number of paragraphs in your text instantly. Paste content and get an exact paragraph count in one click.

Remove Dollar Signs from Numbers

Strip dollar signs from currency values. Paste your list and get clean numbers instantly. Use it in your browser for quick, copy-ready results.

Remove Repetitive Spaces

Collapse multiple spaces into a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.

Sentence Count Calculator

Count the total number of sentences in your text instantly. Paste content and get an exact sentence count in one click.

String to Lowercase

Convert text to lowercase instantly. Paste your text and get lowercase output in seconds. Use it in your browser for quick, copy-ready results.

String to Uppercase

Convert text to uppercase instantly. Paste your text and get uppercase output in seconds. Use it in your browser for quick, copy-ready results.

Text Case Inverter

Invert the case of every letter. Lowercase becomes uppercase and uppercase becomes lowercase. Works fast in your browser.

Text Length Calculator

Calculate the total character length of your text instantly. Paste any text and get an exact count in one click.

Text Reverser

Reverse text line by line. Paste your content and get reversed output instantly. Use it in your browser for quick, copy-ready results.

AI Token Count Calculator

Estimate AI token count instantly from your text input. Paste content and get a quick token estimate for prompt planning.

Truncate Lines by Character Count

Trim each line to a maximum character length. Set a line length count and truncate all lines instantly. In your browser.

Truncate Lines by Word Count

Trim each line to a maximum number of words. Set a word count and truncate all lines instantly. Works fast in your browser.

Unique Word Count Calculator

Count unique words in your text instantly. Paste content and get an exact unique word total in one click. In your browser.

Word Count Calculator

Count the total number of words in your text instantly. Paste any content and get an exact word count in one click.