Hoe zet je tekst om naar hexadecimaal?
Codeer de tekst als bytes (UTF-8) en schrijf elke byte als twee hexcijfers. "Hello" bestaat uit de bytes 72, 101, 108, 108, 111, in hex 48 65 6C 6C 6F. Elk hexcijfer staat voor 4 bits, dus één byte is altijd precies twee cijfers (00–FF).
Hextabel voor letters en cijfers
| Teken | Hex | Teken | Hex | Teken | Hex |
|---|---|---|---|---|---|
| A | 41 | a | 61 | 0 | 30 |
| B | 42 | b | 62 | 1 | 31 |
| C | 43 | c | 63 | 2 | 32 |
| D | 44 | d | 64 | 3 | 33 |
| E | 45 | e | 65 | 4 | 34 |
| F | 46 | f | 66 | 5 | 35 |
| G | 47 | g | 67 | 6 | 36 |
| H | 48 | h | 68 | 7 | 37 |
| I | 49 | i | 69 | 8 | 38 |
| J | 4A | j | 6A | 9 | 39 |
| K | 4B | k | 6B | Spatie | 20 |
| L | 4C | l | 6C | . | 2E |
| M | 4D | m | 6D | , | 2C |
| N | 4E | n | 6E | ! | 21 |
| O | 4F | o | 6F | ? | 3F |
| P | 50 | p | 70 | ||
| Q | 51 | q | 71 | ||
| R | 52 | r | 72 | ||
| S | 53 | s | 73 | ||
| T | 54 | t | 74 | ||
| U | 55 | u | 75 | ||
| V | 56 | v | 76 | ||
| W | 57 | w | 77 | ||
| X | 58 | x | 78 | ||
| Y | 59 | y | 79 | ||
| Z | 5A | z | 7A |
Tekst naar hex in Python, JavaScript en Excel
| Waar | Tekst → hex | Hex → tekst |
|---|---|---|
| Python | "Hello".encode().hex() | bytes.fromhex("48656c6c6f").decode() |
| JavaScript | [...new TextEncoder().encode(s)].map(b=>b.toString(16).padStart(2,"0")).join("") | new TextDecoder().decode(Uint8Array.from(h.match(/../g),x=>parseInt(x,16))) |
| Excel | =DEC2HEX(UNICODE(A1)) per teken | =UNICHAR(HEX2DEC("48")) |
De Excel-functie UNICODE geeft het codepunt terug, dat alleen bij ASCII-tekens gelijk is aan de UTF-8-byte.
Hex naar tekst: welke formaten worden geaccepteerd?
Paren met spaties (48 65), één doorlopende reeks (4865), C-stijl 0x48 0x65 en ge-escapet \x48\x65. Komma's en dubbele punten worden genegeerd.
Waarom worden sommige tekens 2–4 hexbytes?
UTF-8 slaat tekens buiten ASCII op in meerdere bytes: "é" is C3 A9, "한" is ED 95 9C, en "😀" is F0 9F 98 80.
Bronnen: RFC 3629 (UTF-8) · Microsoft Support, UNICODE function. Gecontroleerd in oktober 2026.