Yes: spaces, tabs and line breaks are characters, and they count toward a character limit unless the limit says "without spaces". A space is one character. A tab is one character, however wide it looks. A line break is one character on most systems and two on Windows and in submitted web forms. Invisible characters that are not whitespace at all, such as the zero-width space, count as well.
What each kind of whitespace costs
Unicode gives 25 code points the property White_Space. These are the ones you are likely to meet:
| Character | Code point | Where it comes from | Characters | UTF-8 bytes |
|---|---|---|---|---|
| Space | U+0020 | The space bar | 1 | 1 |
| Tab | U+0009 | The Tab key | 1 | 1 |
| Line feed (LF) | U+000A | Enter on macOS and Unix-like systems, and in web text boxes | 1 | 1 |
| Carriage return (CR) | U+000D | The first half of a Windows line break | 1 | 1 |
| CR followed by LF | U+000D U+000A | Enter on Windows | 2 code points | 2 |
| No-break space | U+00A0 | Typed on purpose, or copied in with formatted text | 1 | 2 |
| Narrow no-break space | U+202F | Typographic spacing | 1 | 3 |
| En space, em space, thin space | U+2002, U+2003, U+2009 | Typeset text | 1 each | 3 each |
| Ideographic space | U+3000 | East Asian text | 1 | 3 |
| Line separator, paragraph separator | U+2028, U+2029 | Rare in everyday text | 1 each | 3 each |
Every one of them is a character in the text. Width on screen has nothing to do with the count: a tab that spans eight columns and a thin space you can barely see are one character each.
Line breaks: one character or two
A line break is not stored the same way everywhere. The Unicode Standard's newline guidelines list the conventions by platform: Unix and macOS use a single line feed (LF), Windows uses a carriage return followed by a line feed (CRLF), and the classic Mac OS used a carriage return alone.
So the same two lines can have two lengths:
| Text | Visible characters | Code points | UTF-16 units | UTF-8 bytes |
|---|---|---|---|---|
Line one, LF, Line two |
17 | 17 | 17 | 17 |
Line one, CRLF, Line two |
17 | 18 | 18 | 18 |
The visible-character count stays at 17 because Unicode's segmentation rules never split a CR from the LF that follows it, so the pair is treated as one unit. Every other measure sees two. A 40-line text saved with Windows line breaks is 39 code units longer than the same text saved with LF.
A blank line between paragraphs is a second line break, so each paragraph gap costs two characters, or four code units in the Windows form.
Where the difference catches people out:
- Web forms. A browser counts each line break in a multi-line box as one character, then sends it to the server as CRLF. A server that counts what it receives sees two. The guide on character limits in online forms covers this in detail.
- Files and fields measured in bytes or code units. A text that fits when counted on a Mac can be over the limit once it has been saved on Windows.
- Comparing two counters. If two tools differ by exactly the number of line breaks in the text, this is why.
Tabs
A tab is a single character whose width is decided by whatever displays it. Two consequences follow.
First, an editor set to insert spaces when you press Tab produces a different count from one that inserts a real tab. The word indented after one tab is 9 characters; after four spaces it is 12.
Second, a tab does not survive everywhere. On a web page with the default styling, a tab in running text is turned into an ordinary space when the page is displayed. In a text message a tab is outside the basic SMS alphabet (GSM-7), so a single one switches the whole message to Unicode encoding, which leaves much less room; the SMS Character Counter flags it.
Non-breaking and other special spaces
A no-break space (U+00A0) looks exactly like an ordinary space. Its job is to stop a line from wrapping at that point, as between a number and its unit. It differs from the ordinary space in three ways that affect counting:
- It is two bytes in UTF-8 where the ordinary space is one.
- A tool that computes "without spaces" by removing only the ordinary space will leave it in.
- It is not in the GSM-7 alphabet, so in a text message it forces Unicode encoding just as a tab does. The SMS counter on this site offers to replace it with an ordinary space.
The other special spaces in the table behave the same way: one character each, three bytes in UTF-8, and invisible as a problem until a byte limit or a strict system is involved.
Zero-width characters: not whitespace, still characters
Some characters take up no width at all and are not whitespace by Unicode's definition. None of the following has the White_Space property. They are formatting characters, and each one is a real code point in the text.
| Character | Code point | UTF-8 bytes | How this site counts it |
|---|---|---|---|
| Zero width space | U+200B | 3 | 1 character |
| Zero width non-joiner | U+200C | 3 | Joins the character before it: 1 more code point, no extra character |
| Zero width joiner | U+200D | 3 | Joins the character before it: 1 more code point, no extra character |
| Word joiner | U+2060 | 3 | 1 character |
| Zero width no-break space (byte order mark) | U+FEFF | 3 | 1 character |
| Soft hyphen | U+00AD | 2 | 1 character |
Each is one UTF-16 code unit, so each takes one character of a browser-enforced limit. The zero width joiner is also what binds the people in a family emoji into one picture, which is a legitimate use; a stray one in the middle of a word is not.
Because they are not whitespace, a "without spaces" count does not remove them. On this site, a, a zero width space, b is 3 characters with or without spaces, although only two are visible.
These characters are easy to pick up without noticing when you copy text from somewhere else. Two signs give them away in the Character Counter: a figure above zero for "Other" in Advanced statistics, which counts invisible control and formatting characters, or "Unicode code points" coming out higher than "Characters" for text that looks plain.
Trailing and double spaces
Whitespace you cannot see is counted like any other.
| Text | Characters |
|---|---|
Done. |
5 |
Done. followed by one space |
6 |
Done. followed by two line breaks |
7 |
One. Two. Three. |
16 |
One. Two. Three. with two spaces after each period |
18 |
Double spaces are easy to miss on a web page in particular. With the default styling, a browser collapses a run of whitespace into a single space when it displays text. The published page shows one space; the text that was counted had two.
Trailing spaces and blank lines at the end of a text are the cheapest characters to recover. Remove them yourself; you cannot assume the destination will trim them for you.
How this site's counter treats whitespace
- Characters counts every whitespace character as one.
- Characters without spaces leaves out every whitespace character: spaces, tabs, line breaks, no-break spaces and the rest of Unicode's list. It is not limited to the ordinary space. Zero-width characters stay in, because they are not whitespace.
- Spaces, in Advanced statistics, counts the ordinary space (U+0020) only. Whitespace characters counts all of them. The difference between the two tells you how many tabs, line breaks and special spaces the text contains.
- Lines are logical lines. CRLF, CR and LF each end a line. A final line break ends the last line; it does not add an empty one.
- Paragraphs are blocks separated by one or more blank lines. A single line break does not start a new paragraph.
- Words are not affected by extra whitespace. Two spaces between words do not create an empty word.
One thing to know when you paste: a browser text box converts pasted line breaks to LF. A Windows line break therefore counts as one character in the tool, in every unit, including UTF-16 code units and UTF-8 bytes. If your text is going somewhere that stores CRLF, add one per line break to those two figures.
A short example with the invisible characters marked:
a[tab]b[no-break space]c d[line break]
That is 8 characters, of which 4 are whitespace and 1 is an ordinary space. Characters without spaces: 4.
Other tools draw the line in slightly different places. JavaScript's built-in definition of whitespace, for instance, includes U+FEFF, which Unicode does not class as whitespace, and leaves out U+0085, which Unicode does. Two "without spaces" figures can differ on unusual text for that reason alone. The guide to counting with and without spaces explains how to find out which definition a tool uses.
Cleaning up before you count
- Trim the end. Delete trailing spaces and blank lines after the last sentence.
- Collapse double spaces. Search for two spaces and replace them with one, repeating until none are found.
- Check for special spaces. If "Whitespace characters" minus "Spaces" is more than your tabs and line breaks, something else is in there. Replace no-break spaces with ordinary ones if the text is going into an SMS or a byte-limited field.
- Remove stray zero-width characters. If "Other" is above zero in text that should be plain, paste the text into the counter a section at a time to find where the character is, then delete and retype that part.
- Budget for line breaks. If you do not know how the destination stores them, allow two characters for each.