DevKits

ASCII 126

Tilde (~)

Printable ASCII

Tilde. Home directory shortcut in Unix. Bitwise NOT in C-family languages.

Common uses & context

The character '~' — Tilde — has ASCII code 126 (0x7E), octal 0176, binary 01111110. Tilde. Home directory shortcut in Unix. Bitwise NOT in C-family languages.

Punctuation and symbol codes carry the most syntactic weight per byte in programming: a single '~' can change how a parser reads an entire expression. When '~' needs to appear as literal data rather than syntax, you often have to escape it — in string literals, in regular expressions, in URLs (where it becomes %7E), or in HTML. Knowing its exact code point (126) helps when you filter, validate, or sanitize input byte by byte.

All encodings at a glance

Decimal126
Hexadecimal0x7E
Octal0176
Binary01111110
HTML numeric entity~
URL encoding%7E
UTF-8 bytes0x7E

Code snippets

JavaScript

String.fromCharCode(126); // "~"
126.toString(16); // "7e"

Python

chr(126)           # '~'
ord(chr(126))      # 126
hex(126)           # '0x7e'

HTML

&#126;   <!-- numeric entity (no named entity for this character) -->

Programming notes

  • Code 126 (0x7E); URL-encoded form%7E.
  • In HTML the numeric entity is &#126;.
  • When used as literal data in regex or strings, '~' usually needs escaping — check the rules for your language.

Frequently asked questions

What character is ASCII code 126?

ASCII code 126 is the character '~' (Tilde). In hexadecimal it is 0x7E, in octal 0176, and in binary 01111110.

What is 0x7E in ASCII?

Hexadecimal 0x7E equals decimal 126, which is the character '~' (Tilde). To convert hex to ASCII yourself, read the two hex digits as a base-16 number (0x7E = 126) and look up that code point.

How do I write the character with code 126 in code?

In JavaScript use String.fromCharCode(126); in Python use chr(126); in HTML use the numeric entity &#126;. In a URL it is percent-encoded as %7E, and in UTF-8 it is stored as the byte sequence 0x7E.

Nearby codes

Encode & convert this character