ASCII Code for Space: Decimal 32, Hex 20, and How to Confirm a Real U+0020

The ASCII code for space is 32 (hex 0x20), the same as Unicode U+0020. Learn how to check whether a space in your text is a regular space or an invisible lookalike.

The ASCII code for the space character is 32 in decimal, which is 20 in hexadecimal. In Unicode, the same character is U+0020, named SPACE. This guide shows the space character's value in each common notation, explains why a gap that looks like a space may not be one, and gives step-by-step ways to confirm that a character in your text really is U+0020 without changing anything else in the text.

The space character in every common notation

Notation | Value for the regular space
Decimal (ASCII code) | 32
Hexadecimal | 0x20
Octal | 040
Binary (8-bit) | 00100000
Unicode code point | U+0020 (SPACE)
UTF-8 bytes | 20 (a single byte)
HTML numeric reference | or
URL percent-encoding | %20

ASCII is a 7-bit character set with codes 0 through 127. Codes 0 to 31 and 127 are control characters, such as tab and line feed. Code 32 is the first non-control character. It prints as blank space, so it is sometimes grouped with the printable characters and sometimes treated separately. Unicode kept the first 128 ASCII codes unchanged. That is why searches for "Unicode character 32" and "ASCII 32" point to the same character: decimal 32 is U+0020. In UTF-8, the space is stored as the single byte 0x20, exactly as in ASCII.

What inspecting a space actually tells you

Checking a space works like this. You give a character inspection method some text: a string in a script, a file, or a pasted snippet. It reports the numeric identity of each character, such as its code point (for example U+0020) or its encoded bytes (for example 20). It does not change the text. The point is to tell visually identical gaps apart, because many characters render as blank space but are not the ASCII space. Searches, comparisons, data imports and code parsers treat them differently.

Some common lookalikes and invisible characters you may find instead of U+0020:

Character | Code point | UTF-8 bytes | Typical source
Space | U+0020 | 20 | Normal keyboard spacebar
Character tabulation (tab) | U+0009 | 09 | Tab key, spreadsheet exports
No-break space | U+00A0 | C2 A0 | Word processors, web pages ( )
En space | U+2002 | E2 80 82 | Typesetting, copied documents
Thin space | U+2009 | E2 80 89 | Typesetting, number formatting
Zero width space | U+200B | E2 80 8B | Web content, copied text (no visible width)
Narrow no-break space | U+202F | E2 80 AF | Number and unit formatting in some locales
Ideographic space | U+3000 | E3 80 80 | East Asian text input
Zero width no-break space / BOM | U+FEFF | EF BB BF | Start of some files

Step by step: confirm that a space is U+0020

  • 1. Isolate the suspicious text. Copy the smallest string that contains the gap, ideally with one visible character on each side, such as a b.
  • 2. Pick an inspection method. Use a programming language's character functions, a byte-dump command, or a regular expression, as shown below.
  • 3. Read the value of the gap. A regular space shows as 32, 0x20, U+0020, or the single byte 20.
  • 4. If you see any other value, such as 160, U+00A0, or the bytes C2 A0, the gap is a lookalike, not the ASCII space.
  • 5. Verify after any cleanup. If you replace lookalikes, run the same check again and confirm that only the intended characters changed.

Method 1: Python

Python's ord() function returns a character's code point as an integer. The example below prints each character with its decimal value and its U+ notation. Example, not a captured run: for the input a, space, b, the documented behavior of ord() means the middle line should show 32 and U+0020.

text = "a b"
for ch in text:
    print(repr(ch), ord(ch), f"U+{ord(ch):04X}")

# Expected based on ord() behavior:
# 'a' 97 U+0061
# ' ' 32 U+0020
# 'b' 98 U+0062

If the gap were a no-break space, repr() would display it as '\xa0' and ord() would return 160. That makes the difference visible even though both look blank on screen.

Method 2: JavaScript

In JavaScript, codePointAt() returns the code point at a given position. Example:

const text = "a b";
for (const ch of text) {
  const cp = ch.codePointAt(0);
  console.log(JSON.stringify(ch), cp, "U+" + cp.toString(16).toUpperCase().padStart(4, "0"));
}
// A regular space should report 32 and U+0020.

Method 3: Byte dump on the command line

On Linux and macOS, od and hexdump show the raw bytes of text or a file. This is useful when you cannot easily open the content in a script. Example:

printf 'a b' | od -An -tx1
# Regular space: 61 20 62

printf 'a\302\240b' | od -An -tx1
# No-break space in UTF-8: 61 c2 a0 62

hexdump -C yourfile.txt

In the dump, a regular space is always the single byte 20. A sequence such as c2 a0 or e2 80 8b where you expected a space means a different Unicode character is present. Byte values depend on the file's encoding. The values above assume UTF-8.

Method 4: Find every space that is not U+0020

To scan longer text, search for whitespace that is not the ASCII space, plus the zero-width characters. Zero-width characters need separate handling because they are often not classed as whitespace. Example pattern in Python:

import re

pattern = re.compile(r"[^\S ]|[\u200B-\u200D\uFEFF]")
text = "price:\u00a010\u200b USD"

for m in pattern.finditer(text):
    print(m.start(), f"U+{ord(m.group()):04X}")
# Reports the position and code point of each non-ASCII-space gap.

The class [^\S ] means any whitespace character except the literal space. It also matches tabs and line breaks, so filter those out if they are expected in your text. The same idea works in JavaScript with the pattern /[^\S ]|[\u200B-\u200D\uFEFF]/g.

Avoiding unintended changes

Finding a non-ASCII space does not always mean it should be replaced. A no-break space can be deliberate, for example to keep a number and its unit on one line. A tab can be a field separator. A byte order mark can be expected by the program reading the file. Replace only the characters you have identified and intend to change, and work on a copy of the original. Afterwards, rerun the same inspection to confirm that each remaining gap reports U+0020, or the character you deliberately kept.

Evidence note

The values in this guide come from the ASCII and Unicode standards and from the documented behavior of the functions shown. No measurements of specific inspection tools were supplied, so this guide does not compare or recommend particular applications. The code snippets are illustrative examples, and their expected output is described from documented behavior rather than from a recorded run.