Space Counter

Count spaces in your text and find tabs, line breaks, non-breaking spaces and double spaces hiding in it.

Spaces

0

All whitespace

0

Tabs

0

Line breaks

0

Non-breaking spaces

0

Runs of 2+ spaces

0

Share of characters

0%

Find out how much of your text is empty space

Whitespace is invisible by design, which is exactly why it causes problems. A form rejects your text for being too long because of trailing spaces. A spreadsheet import fails because of a tab. A product title looks fine on screen but won't match in a database because of a non-breaking space copied from a web page. This space counter makes the invisible visible. Paste text above to count the regular spaces, all whitespace combined, tabs, line breaks, non-breaking spaces and runs of two or more spaces, plus the share of your text that's taken up by spaces.

What each figure means

  • Spaces: ordinary spaces, the character you get from the space bar. This is the headline figure.
  • All whitespace: every whitespace character, including spaces, tabs, line breaks, non-breaking spaces and the less common Unicode spaces.
  • Tabs: tab characters, usually from code, spreadsheets or documents indented with the Tab key.
  • Line breaks: the number of times the text breaks onto a new line, including blank lines.
  • Non-breaking spaces: a special space that stops a line break between two words, as in "10 kg" or "Mr Smith". It looks identical to a normal space but behaves differently.
  • Runs of 2+ spaces: places where two or more ordinary spaces sit together. Each run counts once, however long it is.
  • Share of characters: spaces as a percentage of all characters.

Why count spaces?

The most common reason is cleaning up text. Double spaces creep in from old typing habits (two spaces after a full stop was standard on typewriters), from copying between applications, and from justified text in PDFs. Most style guides now call for a single space after a full stop, and double spaces look uneven in proportional fonts. A count of zero for runs of two or more spaces means your text is clean.

Another reason is character limits. Spaces count toward the limit on most platforms, so a block of text with stray trailing spaces and blank lines can fail a 280-character or 2,000-character check that the visible words would pass. Knowing how many spaces you have tells you how much room a quick clean-up would free.

Developers and data analysts count whitespace to debug imports and comparisons. Two strings that look identical but don't match often differ by a trailing space, a tab instead of spaces, or a non-breaking space. In code, mixed tabs and spaces cause indentation errors in languages like Python and YAML. Programmers also use space counts to check formatting rules in source files.

Some people need a space count for its own sake. Typing exercises and keyboarding lessons count keystrokes, including spaces. Teachers sometimes ask for word-spacing checks in handwriting and typing practice. And a few character-based pricing schemes for engraving, signage and translation treat spaces differently from letters, so the space count is part of the quote.

Non-breaking spaces: the hidden trouble-maker

Non-breaking spaces deserve special mention. They're inserted automatically by many word processors (French typography puts one before a colon or question mark), by HTML entities ( ) and by copy-and-paste from web pages. They look exactly like normal spaces, so you'd never know they were there, but search, find-and-replace, spreadsheet formulas and database lookups treat them as different characters. If the non-breaking space count is above zero and you're preparing text for data entry or code, replace them with ordinary spaces.

How to remove extra spaces

Once you know they're there, getting rid of extra spaces is easy. In most word processors, open find and replace, search for two spaces, replace with one, and repeat until nothing is found. The full Word Counter on this site has a one-click "remove extra spaces" clean-up that collapses runs of spaces, trims the ends of lines and removes empty lines. For non-breaking spaces, many editors let you search for them by pasting one into the find box.

Spaces in different languages

The share of spaces says something about the language and style of a text. English prose usually runs at 15 to 18% spaces. German, with its long compound words, is lower. Chinese and Japanese use almost no spaces between words. Very technical writing with long words has fewer spaces, and simple prose with short words has more. If the share in an English document is well above 20%, check for double spaces, indentation or wide gaps used for layout.

Spaces in code and data

In programming, whitespace is often meaningful. Python and YAML use indentation to define structure, so mixing tabs and spaces can change how code runs or stop it from running at all. Most style guides pick one: Python's PEP 8 recommends four spaces per indentation level, while Go formats code with tabs. If the tab count isn't zero in a file that should use spaces, or the other way round, that's worth fixing before you commit.

In data files, trailing spaces are a frequent cause of failed lookups. A customer ID of "A1023 " won't match "A1023" in most databases or spreadsheet formulas, even though they look identical. Before importing, many analysts run a trim on every field. The space counter is a quick way to check whether that's needed. Paste a column and compare the space count with what you'd expect from the values themselves.

Spaces matter in URLs and file names too. A space in a URL is encoded as %20, which looks untidy and can break links copied into emails or documents. Hyphens are the usual replacement in web addresses.

Related tools

To count characters with the spaces taken out, use the Character Counter Without Spaces. To find empty lines specifically, the Blank Line Counter also shows the longest run of consecutive blank lines. For a full breakdown of every character in your text, try the Character Frequency Counter. Your text is analysed locally and never uploaded.

How to use it

  1. 1

    Paste your text

    Copy from any document, form, spreadsheet or code file.

  2. 2

    Read the space count

    The main figure counts ordinary spaces.

  3. 3

    Check for hidden whitespace

    Look for tabs, non-breaking spaces and runs of double spaces.

  4. 4

    Clean up and recheck

    Remove extra spaces in your editor or the Word Counter, then paste again to confirm.

Features

Every kind of whitespace

Spaces, tabs, line breaks, non-breaking and Unicode spaces.

Double-space finder

Counts runs of two or more spaces.

Share of text

Spaces as a percentage of all characters.

Private

Text is analysed in your browser.

Häufig gestellte Fragen

Does the space count include line breaks?

The headline figure counts ordinary spaces only. Line breaks, tabs and other whitespace are counted separately and included in 'All whitespace'.

What is a non-breaking space?

A space that stops a line break between two words. It looks like a normal space, but search, spreadsheets and code treat it as a different character.

Should I use one or two spaces after a full stop?

One. Most modern style guides recommend a single space, and double spaces look uneven in proportional fonts.

How are runs of double spaces counted?

Each place where two or more spaces sit together counts once, however many spaces are in the run.

How do I remove extra spaces?

Use find and replace to swap two spaces for one until none are left, or use the remove extra spaces option in the Word Counter.

Is my text saved?

No. Counting runs on your device and nothing is stored.

Rate Space Counter

No account needed, and ratings are anonymous.

How useful was this tool?
No ratings yet — be the first

Further reading

All articles →