Skip to content
ToolkitHub

Binary Encode/Decode

Binary encoder and decoder

Guide

Text as ones and zeros

By Logappradeep · ServiceNow developer

Every piece of text on a computer is ultimately stored as bits, ones and zeros. A binary converter makes that layer visible by writing each byte of a string as eight binary digits. It is a favorite for learning how computers represent data, for checking bit patterns, and for decoding binary messages in puzzles and capture-the-flag challenges.

From character to bits

The conversion has two steps. First, the text is encoded into bytes using UTF-8. Then each byte is written as an 8-bit group, padded with leading zeros so every group has the same width. The letter A is byte 65, which is 01000001, and Hi becomes:

H        i
01001000 01101001

Each position is a power of two, from 128 on the left down to 1 on the right. For 01001000, the bits for 64 and 8 are set, and 64 + 8 = 72, the code for H.

What multi-byte characters look like

UTF-8 has a neat structure that becomes obvious in binary. The first bits of each byte tell a decoder how to read it:

  • 0xxxxxxx: a single-byte ASCII character.
  • 110xxxxx 10xxxxxx: a two-byte character, such as é = 11000011 10101001.
  • 1110xxxx followed by two continuation bytes: a three-byte character, such as many CJK characters and the euro sign.
  • 11110xxx followed by three continuation bytes: a four-byte character, such as most emoji.

Every continuation byte begins with 10, which lets a decoder find character boundaries even when it starts reading in the middle of a stream.

Where binary representation matters

  • Learning and teaching how encodings, bytes, and bits relate.
  • Bit flags and masks, where each bit of a value switches an option on or off.
  • Network and protocol work, such as reading header fields or subnet masks bit by bit.
  • Puzzles and CTFs, where messages are often hidden as strings of ones and zeros.

Pitfalls

  • Leading zeros matter. 1000001 and 01000001 are the same number, but when bytes are run together without spaces, dropping a zero shifts every following bit and scrambles the text.
  • Whole bytes only. Decoding reads space- or comma-separated groups as bytes, or splits one long run into 8-bit chunks when its length is a multiple of eight. A continuous run of any other length is rejected, because it cannot be divided into whole bytes.
  • Binary text is huge. Each byte becomes eight characters plus a separator, about nine times the original size, so it is a display format, not a storage format.
  • "Binary file" means something else. A binary file is any non-text file, such as an image or executable, not a file of written ones and zeros.

Everything is converted locally in your browser as you type.

Frequently asked questions

Why is each character eight digits long?

A byte has 8 bits, and each bit is written as one digit. Leading zeros are kept so every byte has the same width.

Why does é produce two groups?

In UTF-8, é takes two bytes, 11000011 and 10101001. Characters outside ASCII use two to four bytes.

How do I decode binary without spaces?

Paste it as one run. If its length is a multiple of eight, it is split into bytes automatically, and optional 0b prefixes are ignored.

Can I convert a number to binary here?

This tool converts text characters. To turn a number like 42 into 101010, use the Base Converter.