ForHosting KIT · Text & AI

Count tab characters

A three-line code snippet with one indented line shows 1 tab on 1 line. Only real tab characters count, never four spaces or a non-breaking space, so you can catch mixed indentation or leftover spreadsheet separators. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
function f() { return 1; }
You get
Tabs
1
Lines with tabs
1
Length
27
Non tabs
26

Developers, data engineers, editors, and teachers use a precise tab tally every day to spot mixed indentation before a lint run, to verify that a paste from a spreadsheet still carries field separators, and to gate imports that must not contain invisible control characters. The engine is fully deterministic: it walks the string once, counts only true tab code units, and never calls the network, samples randomness, or depends on the clock. Spaces, non-breaking spaces, and other Unicode whitespace are ignored for the tab total so a style guide that bans tabs can fail a sample with confidence.

Tab counting answers a focused product question: how many horizontal tab characters live in this exact string, and on how many lines do they appear. A tab here means only Unicode U+0009, the single character produced by the Tab key and by the escape sequence backslash-t in source code. Four ordinary spaces are never counted as a tab, a non-breaking space is never counted as a tab, and a vertical tab or form feed is never counted either.

That narrow definition keeps the metric stable across editors, operating systems, and languages, and it matches what most style guides mean when they say no tabs allowed. There is no option to treat four spaces as one tab, no mode that expands tabs to columns, and no silent coercion of null into an empty success.

Where tab tallies fit in code review, data import, and teaching

Students meet tab counting when a coding style lab forbids mixed indentation, when a data-entry exercise pastes TSV samples, or when a spreadsheet export must be checked before a grading script. Teachers can pre-generate answer keys that show the expected tab total without trusting opaque office macros that expand or hide control characters differently on each machine. Data and operations teams measure noisy ticket fragments, log lines, and CSV-like dumps when a pipeline must reject files that still contain tab separators after a space-only migration.

Support staff paste a snippet from a customer to confirm whether invisible tabs are breaking a parser. Pair it with tabs-to-spaces conversion, whitespace removal, or character-count tools when you are building a small lab of free, deterministic text helpers for forms, CMS prep, and data hygiene.

Mixed indentation audits

Count tabs in a code snippet before lint or format so space-only style guides fail samples that still hide tab characters.

TSV and spreadsheet paste checks

Verify how many tab field separators remain in pasted tabular data before import, ETL, or grading scripts.

What does the count-tab-characters tool cost?

It is free in your browser on this page.

Which characters count as tabs?

Only the horizontal tab character Unicode U+0009 (the Tab key / backslash-t). Spaces, non-breaking spaces, and other whitespace are not counted as tabs.

What happens if the text field is empty?

You must provide a non-empty string; blank form fields do not become silent zero successes.

Does this convert tabs to spaces?

No. It only counts horizontal tabs. Use a dedicated tabs-to-spaces converter if you need expansion to a fixed tab stop width.

Is the result the same every time?

Yes. The count is a pure, deterministic string scan with no network, randomness, or clock dependency, so identical input always yields identical output.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/str/count-tabs

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/str/count-tabs \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"function f() {\n\treturn 1;\n}"}'
{
  "text": "function f() {\n\treturn 1;\n}"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.count_tabs",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

This count-tab-characters tool measures any non-empty text string and reports how many horizontal tab characters (Unicode U+0009, the familiar backslash-t) appear anywhere in the payload. Empty input is rejected with a clear invalid_input error so a blank form field cannot become a silent zero success. Use it free in the browser for quick audits and homework, or call the API at $0.002 per successful request when you need reproducible tallies in CI, pipelines, or teaching demos.

What tab counting means and what the response contains

The response is intentionally small and stable: text echoes the input so you can audit what was measured, tabs is the integer total of U+0009 code units, has_tabs is true when that total is greater than zero, lines_with_tabs counts how many lines (split on CR, LF, or CRLF) contain at least one tab, length is the full character length of the string, non_tabs is length minus tabs, and method is the fixed tag count_tabs for logs and multi-tool pipelines. The engine either builds complete integer metrics inside the supported length or rejects the request with invalid_input. Rejected cases include a missing text field, a null value, an empty string, objects and arrays that are not plain text, and any payload longer than the documented maximum character count.

How the text field is read and how tallies stay reproducible

The value must be a non-empty string; finite numbers and bigints are stringified first so a bare product code typed as a number still produces a stable digit string that, by definition, has zero tabs. Counting uses a single linear pass with a strict equality check against the tab character—no network dictionary, no machine-learning model, and no locale tables. The preferred field is text, but aliases input, string, value, content, and s are accepted so query strings, spreadsheets, and typed forms can reuse the same contract without renaming columns. Booleans, plain objects, and arrays are rejected with a clear message so a mistaken JSON body does not become the word true or an unhelpful object dump. Empty string is always invalid_input: the product promise is count tabs in text, not invent a zero success for a blank submit. Length is capped at one hundred thousand characters so a runaway paste cannot monopolize a Worker; longer payloads fail with an explicit limit message rather than a truncated silent cut. Lines are split with a fixed CR, LF, or CRLF rule so a file from Windows and a file from Unix report the same lines_with_tabs for the same visual content. Pair the free browser run on this page with the priced API when you need the identical tallies inside an automated pipeline without shipping your own scanners.

Where tab tallies fit in code review, data import, and teaching

On this page the work runs entirely in your browser; through the API each successful count costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split—free interactive exploration and a priced, identical API—matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the numeric result.

Deterministic CI fixtures

Generate reproducible tab totals for unit tests, golden files, and pipeline gates that must not invent whitespace rules.

Read the full KIT documentation →