Learn binary, octal, decimal, and hexadecimal number systems

What binary, octal, decimal and hexadecimal are, how text-to-number conversion works, and when the result is useful or when plain text is the better choice.

The short answer

Binary, octal, decimal and hexadecimal are four ways of writing the same numbers. They differ only in their base, meaning how many distinct digits each position can hold. Binary is base 2, octal is base 8, decimal is base 10 and hexadecimal is base 16. The number seventy-two is the same quantity whether it is written as 01001000, 110, 72 or 48.

In text transformation, these systems appear when a tool turns characters into the numbers a computer uses to store them. That conversion is useful for learning, debugging and puzzles. It is a poor choice for communicating with people, because the result carries no readable meaning until someone decodes it.

How the four number systems work

All four systems use positional notation. Each position is worth the base raised to a power, counting from zero on the right. In decimal, 345 means 3 hundreds, 4 tens and 5 ones. In binary, 1011 means one eight, no fours, one two and one one, which totals eleven.

System | Base | Digits used | Value of each position (right to left) | Seventy-two written in this system
Binary | 2 | 0 1 | 1, 2, 4, 8, 16, 32, 64, 128 ... | 1001000 (often padded to 01001000)
Octal | 8 | 0 to 7 | 1, 8, 64, 512 ... | 110
Decimal | 10 | 0 to 9 | 1, 10, 100, 1000 ... | 72
Hexadecimal | 16 | 0 to 9, then A to F | 1, 16, 256, 4096 ... | 48

Hexadecimal needs six extra digits beyond 9, so it borrows the letters A to F to represent ten through fifteen. Upper and lower case letters mean the same thing: FF and ff both equal 255.

Why octal and hexadecimal exist

Computers store data as bits, so binary is the native form. Binary is long and hard to read, though, and octal and hexadecimal act as compact shorthand for it. One octal digit stands for exactly three bits, and one hexadecimal digit stands for exactly four bits. A byte (eight bits) therefore always fits in two hexadecimal digits, which is why hex dominates in memory dumps, colour codes such as #FF0000 and Unicode code points written as U+0048. Octal is less common today but still appears in Unix-style file permissions, where a value such as 755 packs three groups of three permission bits.

Decimal   Binary      Octal   Hex
      0   00000000        0    00
      8   00001000       10    08
     15   00001111       17    0F
     72   01001000      110    48
    105   01101001      151    69
    255   11111111      377    FF

How to tell which system a number is in

The digits alone are often ambiguous: 110 is a valid binary, octal, decimal and hexadecimal number, with four different values. Context and prefixes resolve this. These are common conventions, and they vary by programming language and tool.

  • Binary: only 0 and 1, often grouped in eights, sometimes prefixed with 0b.
  • Octal: only digits 0 to 7, sometimes prefixed with 0o, or with a leading 0 in C-family languages.
  • Decimal: digits 0 to 9 with no prefix; in web markup, character references look like H.
  • Hexadecimal: digits plus letters A to F, often prefixed with 0x, written after # in colour codes, after U+ for Unicode code points, or as H in web markup.

What a text-to-binary or text-to-hex conversion actually changes

Unlike mirrored text, upside-down text or Unicode "fonts", which alter how characters look, number-system conversion replaces the stored characters entirely. The word Hi becomes a new string made of digit characters. Nothing about the original letters survives in a form a reader can see. This is a change to the stored text, not to its visual presentation, so no styling, CSS or display setting can turn it back into words. Only decoding can.

The conversion works in two steps. First, each character is mapped to a number using a character encoding. Second, that number is written out in the chosen base. For the letter H, the Unicode code point is 72 in decimal, so the outputs are as follows.

Input: Hi

Character  Decimal  Binary     Octal  Hex
H          72       01001000   110    48
i          105      01101001   151    69

As binary: 01001000 01101001
As hex:    48 69

The encoding matters as much as the base

For basic English letters, digits and punctuation, ASCII, UTF-8 and Latin-1 assign the same values, so most tools agree. Beyond that range, the result depends on which encoding the tool uses, and many tools do not say. One accented letter or emoji can become several bytes, and different encodings produce different bytes for the same character.

Character            Code point   UTF-8 bytes (hex)
é (precomposed)      U+00E9       C3 A9
é (e + combining)    U+0065 U+0301   65 CC 81
😀                   U+1F600      F0 9F 98 80

The two versions of é look identical on screen but are stored differently, so they convert to different numbers. A tool that converts per code point would also give different output from one that converts per UTF-8 byte. When the exact output matters, check whether the tool reports code points or encoded bytes, and which encoding it uses. Then test it with a sample that includes an accented letter and an emoji.

Clarifying ambiguous terms

  • "Binary" can mean text written as 0s and 1s, or a binary file such as an image or program. Converters usually mean the former.
  • "Decimal" in a text converter usually means each character's numeric code written in base 10, not decimal fractions.
  • "Hex" may refer to a hex converter, which outputs digit text, or a hex editor, which shows and edits a file's raw bytes.
  • None of these are "fonts": they do not change appearance but substitute entirely different characters.

Will the result stay usable after copying or sharing?

Mechanically, the output tends to travel well. It consists only of basic digits, letters A to F and spaces, which nearly every system handles, so it avoids the missing-glyph boxes that affect decorative Unicode text. No destination-specific testing was supplied for this article, though, so confirm behaviour in the place you intend to paste it.

Practical usability is a different matter. Several limits apply regardless of where the text ends up.

  • Meaning: readers see digits, not words. Unless they decode the text, the message is lost.
  • Accessibility: a screen reader can only announce the digits it is given, so a listener hears a string of numbers instead of the message. No specific assistive technology was tested for this article. Treat the output as unreadable to such users unless a plain-text version accompanies it.
  • Search: search engines and in-app search match the digits, not the original words, so converted text will not be found by searching for what it says.
  • Editing: a single wrong or missing digit corrupts a character, and line wrapping or removed spaces can make the groups impossible to split correctly. Keep fixed-width groups, such as eight binary digits or two hex digits per byte, and a consistent separator.
  • Length: binary output is roughly eight to nine times longer than the original ASCII text, which can run into character limits.

Provide a plain-text equivalent whenever the content must be understood by people, found by search, read by assistive technology, or edited later. Keep the converted form as a supplement, such as a puzzle or a technical illustration, not as the only copy.

Encoding is not encryption

Converting text to binary, octal or hex hides nothing. Anyone with a converter can reverse it instantly, and the patterns are easy to recognise. Do not use it to protect passwords, personal details or anything sensitive. Also do not assume an online converter keeps your input private because it looks simple or says so in its marketing. Its data handling can only be judged from its stated policies or from running the conversion locally.

Identifying the effect and finding a way to produce it

If you have come across text made of 0s and 1s, or of pairs of digits and letters A to F, it is likely an encoded message. Long runs of only 0 and 1 in groups of eight point to binary. Pairs such as 48 65 6C 6C 6F, using only 0 to 9 and A to F, point to hexadecimal; that example decodes to Hello in ASCII. Three-digit groups with no digit above 7 may be octal. Groups of two or three ordinary digits, mostly between 32 and 126, may be decimal character codes.

Specific tools were not verified for this article, so none are named here. Useful search terms include "text to binary converter", "binary to text", "hex to ASCII", "text to hex UTF-8", "octal to text" and "decimal to ASCII". Many programming languages and calculator apps can also convert between bases. A programmer or scientific mode in a calculator is the usual place to look, but check that your calculator actually has one. Whatever method you use, confirm it by round-tripping a sample: convert text, convert it back, and check that accented letters and emoji return unchanged.

Is converting text to these number systems right for your use?

Use it when the numbers themselves are the point. Examples include learning how computers store text, inspecting or debugging encoding problems, explaining Unicode, writing code that needs byte values, or setting a puzzle where decoding is part of the fun. Its main benefit is precision: it shows exactly what is stored, including differences that look identical on screen.

The decisive tradeoff is that readability is lost completely. Plain text is the better choice for anything meant to be read, searched, quoted, translated or accessed with assistive technology, and for any attempt to keep information private. If you use a conversion for display, put the plain text alongside it and state which base and encoding you used, so others can decode it reliably.