Skip to main content

Tab to Space Converter

Replace every tab character in your text with a fixed number of spaces. Runs entirely in your browser.

Input

Number of spaces to replace each tab character with.

Output

Converted Text
 
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/tab-to-space-converter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "originalText": "function example() {\n\tconst x = 1;\n\treturn x;\n}",
    "tabSize": "4"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `tab-to-space-converter` tool (Tab to Space Converter) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/tab-to-space-converter/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="Tab to Space Converter — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

Replace every tab character in a block of text or code with a fixed number of spaces. Useful when a style guide, linter, or collaborator requires space-based indentation instead of tabs.

How to use it

  1. Paste your text or code into the input box.
  2. Set Tab Size — the number of spaces each tab becomes (1–8, default 4).
  3. Copy or download the converted result.

Only actual tab characters (\t) are affected — existing spaces are left untouched.

Which tab size should I use?

There's no universal answer — it depends on your project's or language's convention. 2 spaces is common in JavaScript/TypeScript and Ruby; 4 is common in Python and Java; 8 shows up in older C/Unix code. Match whatever your codebase's .editorconfig or style guide already specifies.

Privacy

Everything runs entirely in your browser. Your text is never uploaded to a server.

tabspaceindentationwhitespacecode formattingconverter

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.