BlogUpdated 2026-11-16

ASCII Table + Hex to ASCII in Your Terminal (Copy-Paste Commands)

Full printable ASCII table plus xxd one-liners: hex to ASCII, ASCII to hex, char codes, base64, and where UTF-8 starts.

By Pouya GhourchianiGhourchiani

engineeringdeveloper-tooling

Direct answer

ASCII (American Standard Code for Information Interchange, first published in 1963) gives a number to 128 characters, from 0 to 127. Codes 0 to 31 and 127 are invisible control codes (tab, newline, escape). Codes 32 to 126 are the printable characters: space, punctuation, digits and English letters.

You don’t need a website to convert between them. Every Linux and macOS terminal already has the tools:

Shell
printf 'Hi' | xxd -p        # ASCII to hex   → 4869
echo 4869 | xxd -r -p       # hex to ASCII   → Hi
printf '%d\n' "'A"          # character to code → 65

The printable ASCII table

Each row holds three codes exactly 32 apart. That is why A (65) and a (97) sit on the same row: uppercase and lowercase letters differ by a single bit, 0x20.

Dec Hex Char Dec Hex Char Dec Hex Char
32 0x20 SP 64 0x40 @ 96 0x60 `
33 0x21 ! 65 0x41 A 97 0x61 a
34 0x22 " 66 0x42 B 98 0x62 b
35 0x23 # 67 0x43 C 99 0x63 c
36 0x24 $ 68 0x44 D 100 0x64 d
37 0x25 % 69 0x45 E 101 0x65 e
38 0x26 & 70 0x46 F 102 0x66 f
39 0x27 ' 71 0x47 G 103 0x67 g
40 0x28 ( 72 0x48 H 104 0x68 h
41 0x29 ) 73 0x49 I 105 0x69 i
42 0x2A * 74 0x4A J 106 0x6A j
43 0x2B + 75 0x4B K 107 0x6B k
44 0x2C , 76 0x4C L 108 0x6C l
45 0x2D - 77 0x4D M 109 0x6D m
46 0x2E . 78 0x4E N 110 0x6E n
47 0x2F / 79 0x4F O 111 0x6F o
48 0x30 0 80 0x50 P 112 0x70 p
49 0x31 1 81 0x51 Q 113 0x71 q
50 0x32 2 82 0x52 R 114 0x72 r
51 0x33 3 83 0x53 S 115 0x73 s
52 0x34 4 84 0x54 T 116 0x74 t
53 0x35 5 85 0x55 U 117 0x75 u
54 0x36 6 86 0x56 V 118 0x76 v
55 0x37 7 87 0x57 W 119 0x77 w
56 0x38 8 88 0x58 X 120 0x78 x
57 0x39 9 89 0x59 Y 121 0x79 y
58 0x3A : 90 0x5A Z 122 0x7A z
59 0x3B ; 91 0x5B [ 123 0x7B {
60 0x3C < 92 0x5C \ 124 0x7C |
61 0x3D = 93 0x5D ] 125 0x7D }
62 0x3E > 94 0x5E ^ 126 0x7E ~
63 0x3F ? 95 0x5F _ 127 0x7F DEL

SP is the space character. DEL (127) is a control code, not a printable character.

The control codes you will actually meet

Name Dec Hex Escape What it does
NUL 0 0x00 \0 End of a C string; separator for find -print0 and xargs -0
TAB 9 0x09 \t Horizontal tab
LF 10 0x0A \n Line feed, the Unix newline
CR 13 0x0D \r Carriage return; Windows ends lines with CR LF
ESC 27 0x1B \e Starts terminal colour and cursor sequences
DEL 127 0x7F Delete

You can see them with xxd. A tab, a carriage return and a newline:

Shell
printf 'a\tb\r\n' | xxd
# 00000000: 6109 620d 0a                             a.b..

Three patterns worth remembering

  • Digits: '0' is 0x30, '9' is 0x39. Subtract 0x30 and you have the number.
  • Uppercase: A to Z is 0x41 to 0x5A.
  • Lowercase: a to z is 0x61 to 0x7A, the uppercase value plus 0x20.

Here is the letter A in binary. Bit 5 (the 0x20 bit) is the only difference between A and a:

Shell
printf 'A' | xxd -b
# 00000000: 01000001                                               A

Hex to ASCII and ASCII to hex in the terminal

Shell
# ASCII to hex: full dump, plain hex, or space-separated bytes
printf 'Hi' | xxd                 # 00000000: 4869    Hi
printf 'Hi' | xxd -p              # 4869
printf 'Hi' | od -An -tx1         #  48 69

# Hex to ASCII
echo 4869 | xxd -r -p             # Hi
printf '\x48\x69\n'               # Hi

# Character to code, and code to character
printf '%d\n' "'A"                # 65
printf "\\$(printf '%03o' 97)\n"  # a
python3 -c "print(ord('A'), chr(97))"   # 65 a

On Linux, man ascii prints the complete table, control codes included, in octal, decimal and hex.

Base64 is not ASCII, but it lives next door

Base64 turns any bytes into a safe subset of printable ASCII (letters, digits, +, / and =), so binary data can travel through email, JSON or URLs:

Shell
printf 'Hi' | base64      # SGk=
echo SGk= | base64 -d     # Hi

Where ASCII ends and UTF-8 begins

ASCII stops at 127, so it fits in 7 bits. UTF-8 was designed so that every ASCII byte means exactly the same thing in UTF-8. Everything else (accents, Persian, emoji) uses two to four bytes, all of them 0x80 or higher:

Shell
printf 'سلام' | xxd
# 00000000: d8b3 d984 d8a7 d985                      ........

Four Persian letters, eight bytes. xxd shows dots because those bytes are not printable ASCII.

Some bytes, such as 0xFE, can never appear in valid UTF-8. A Linux filename can still contain them, because to the kernel a filename is just bytes. When a tool “repairs” such a name, it swaps the byte for EF BF BD (the � replacement character), and the next tool in the pipeline can no longer find the file:

Shell
printf 'test_\xFEinvalid' | iconv -f utf-8 -t utf-8
# iconv: illegal input sequence at position 5

I fixed exactly this bug in fd. The story, with the before and after hex dumps, is here: Your Filename Can Be Weird. Your Tools Shouldn’t Make It Weirder.

FAQ

What does ASCII stand for?

American Standard Code for Information Interchange. It was first published in 1963 by the American Standards Association, now ANSI.

How many bits does ASCII use?

7 bits, which gives 128 codes (0 to 127). In practice each character is stored in an 8-bit byte with the top bit set to 0.

What is the ASCII value of A and a?

A is 65 (0x41) and a is 97 (0x61). The difference is always 32 (0x20).

Is ASCII the same as UTF-8?

No, but UTF-8 is a superset of it. Any valid ASCII text is also valid UTF-8 with the same bytes. UTF-8 adds multi-byte sequences for every other character.

What is “extended ASCII”?

Codes 128 to 255 are not part of ASCII. Older code pages such as Latin-1 and Windows-1252 each used them differently, which is why the same byte can look different on different systems. UTF-8 replaced most of them.