Identify space characters by ASCII and Unicode code
How to tell the ASCII space (decimal 32, hex 20, U+0020) apart from no-break, thin, ideographic and zero-width spaces, and when swapping one for another helps or hurts.
Two pieces of text can look identical and still contain different space characters. The ordinary space typed with the space bar is a single, well-defined character in ASCII. Unicode adds many more space-like characters, and some of them have no visible width at all. This guide shows how to identify which one you have by its code, explains what changes when a workflow replaces one space with another, and covers when the plain ASCII space is the safer choice.
The short answer: the ASCII space code
In ASCII, the space character has code 32 in decimal, 20 in hexadecimal, 040 in octal and 0100000 in seven-bit binary. It is the first printable character in the ASCII table, directly after the 32 control codes. Unicode keeps the first 128 ASCII codes unchanged, so the same character is U+0020, with the formal name SPACE. In UTF-8 it is stored as the single byte 0x20, which is why ASCII text with ordinary spaces is also valid UTF-8.
- Decimal: 32
- Hexadecimal: 0x20
- Unicode code point: U+0020 (name: SPACE)
- UTF-8 bytes: 20
- HTML numeric references: or
- URL percent-encoding: %20
Space characters that are not the ASCII space
Unicode groups most visible spaces in the general category Zs (space separator). Only U+0020 is part of ASCII. The rest need more than one byte in UTF-8 and behave differently in line breaking, width or both. Some invisible characters that act like spaces or joiners, such as the zero width space, sit in the format category (Cf) rather than Zs, which matters for tools that only treat Zs as whitespace.
| Character | Code point | Decimal | UTF-8 bytes | In ASCII? | Typical behavior |
| Space | U+0020 | 32 | 20 | Yes | Normal word space; lines may break here |
| No-break space | U+00A0 | 160 | C2 A0 | No | Looks like a space but prevents a line break |
| En space | U+2002 | 8194 | E2 80 82 | No | Fixed width, about half an em |
| Em space | U+2003 | 8195 | E2 80 83 | No | Fixed width, about one em |
| Figure space | U+2007 | 8199 | E2 80 87 | No | Width of a digit; non-breaking; used to align numbers |
| Thin space | U+2009 | 8201 | E2 80 89 | No | Narrow space; lines may break here |
| Hair space | U+200A | 8202 | E2 80 8A | No | Very narrow space |
| Narrow no-break space | U+202F | 8239 | E2 80 AF | No | Narrow and non-breaking; used in some number and unit formats |
| Ideographic space | U+3000 | 12288 | E3 80 80 | No | Full-width space used with CJK text |
| Zero width space | U+200B | 8203 | E2 80 8B | No | Invisible; marks a possible line break; category Cf |
| Word joiner | U+2060 | 8288 | E2 81 A0 | No | Invisible; prevents a line break; category Cf |
| Zero width no-break space / byte order mark | U+FEFF | 65279 | EF BB BF | No | Invisible; mainly used as a byte order mark at the start of a file |
Tab (U+0009, decimal 9), line feed (U+000A, decimal 10) and carriage return (U+000D, decimal 13) are ASCII whitespace control characters, not space characters. Many programs treat them as whitespace, but they are not interchangeable with U+0020.
What replacing a space actually changes
Swapping an ordinary space for a no-break, thin, full-width or zero-width space changes the stored characters, not just the appearance. Unlike CSS spacing or letter-spacing, which only alter how text is displayed, a character substitution travels with the text when it is copied, saved or sent. A string that reads "10 kg" on screen may contain U+0020, U+00A0 or U+202F between the number and unit, and software comparing those strings byte by byte will see them as different.
This is not a reversal or mirroring effect, and it does not involve a styled "font". The letters stay the same; only the separator between them changes. Width and line-breaking rules come from the character's Unicode properties, while the exact rendered width still depends on the font in use.
How to identify which space you have
Because most of these characters look alike or are invisible, the dependable way to identify them is to print each character's code point. Useful search terms for finding a tool that does this include "Unicode code point inspector", "show invisible characters", "hex view" and "character name lookup". Many code editors can also reveal whitespace or show the code of the character under the cursor, though the exact control varies by editor and version.
If you can run a short script, standard library functions are enough. In Python, ord() returns the code point and unicodedata.name() returns the official character name:
import unicodedata
text = "a\u00a0b c\u200bd"
for ch in text:
print(f"U+{ord(ch):04X} {unicodedata.name(ch, '<no name>')}")
For that input, the output identifies each space explicitly:
U+0061 LATIN SMALL LETTER A
U+00A0 NO-BREAK SPACE
U+0062 LATIN SMALL LETTER B
U+0020 SPACE
U+0063 LATIN SMALL LETTER C
U+200B ZERO WIDTH SPACE
U+0064 LATIN SMALL LETTER D
In JavaScript, iterating with for...of and calling codePointAt(0) gives the same information. Iterating this way, rather than by index, avoids splitting characters outside the Basic Multilingual Plane, such as many emoji, into two surrogate halves:
for (const ch of text) {
console.log("U+" + ch.codePointAt(0).toString(16).toUpperCase().padStart(4, "0"));
}
Be aware that "is this whitespace?" checks differ between tools. JavaScript's \s in regular expressions matches U+0020, U+00A0, the other Zs spaces and U+FEFF, but not U+200B. Python's str.isspace() returns True for the no-break space but False for the zero width space. A character can therefore pass one cleanup step and survive another, so check code points rather than relying on a single whitespace filter.
Will the result stay readable and usable after copying?
The non-ASCII spaces generally survive copy and paste as characters, because they are ordinary Unicode text. What varies is how each destination treats them. Some editors, forms or sanitizers may normalize a no-break space to a regular space, strip zero-width characters, or reject non-ASCII input entirely. No destination-specific testing was supplied for this article, so behavior in any particular app, website or platform should be checked directly rather than assumed from one successful paste.
- Search and matching: a search for "hello world" typed with U+0020 may not match text containing U+00A0 or U+200B between the words, depending on whether the search tool normalizes whitespace.
- Editing: invisible characters can make cursor movement, deletion and word selection behave unexpectedly, because the editor counts a character the user cannot see.
- Data and code: identifiers, passwords, usernames, CSV fields and source code are sensitive to exact characters; a stray no-break space or byte order mark can cause failed lookups or syntax errors that are hard to spot.
- Assistive technology: zero-width characters inserted inside words can interfere with how screen readers pronounce or segment text. How specific screen readers handle each character was not tested here and is likely to vary.
- Layout: fixed-width and full-width spaces render at sizes tied to the font, so alignment that looks correct in one font may shift in another.
When text needs to be searchable, editable, machine-parsed or reliably read aloud, keep or restore a plain-text equivalent that uses only U+0020 for word spaces.
Is substituting space characters right for your use?
Using a specific Unicode space is worthwhile when the goal is typographic control in finished, human-read text: a no-break space or narrow no-break space keeps a number with its unit or a title with a name on the same line, a figure space aligns digits, and an ideographic space matches CJK text width. The decisive tradeoff is that these characters are hard to see and are not treated the same way by every search function, filter or program, so they can quietly break matching and parsing.
Plain ASCII spaces are the better choice for code, data files, identifiers, form input, anything that will be searched or compared automatically, and any text where you cannot test the destination. If you receive text that behaves oddly around spaces, inspect the code points first; replacing unexpected characters with U+0020 is usually the simplest fix once you have confirmed they are not serving a deliberate layout purpose.