Hex to binary converter
0xFF in binary is 11111111: each hex digit maps to four bits, so F becomes 1111. Paste a value with or without the 0x prefix and get both the short binary and the nibble-aligned version. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Hexadecimal
- 0xFF
- Input
- 0xFF
- Hex
- FF
- Hex lower
- ff
- Prefixed
- 0xFF
A hex to binary converter turns a base-16 digit string into the exact bit pattern you need for bitmasks, firmware dumps, and classroom place-value checks. Paste a value such as FF, 0xFF, or deadbeef; the tool validates every digit, strips an optional 0x or 0X prefix, maps each hex nibble to four bits, and returns the binary representation with a short step list you can copy into notes or tests.
What hexadecimal means and how it maps to binary
Hexadecimal is base sixteen: each digit place is a power of sixteen, and digits run from zero through nine then A through F for ten through fifteen. Binary is base two: every place is a power of two and every digit is only zero or one. The mapping between them is especially clean because sixteen is two to the fourth power, so each hex digit encodes exactly four bits—one nibble.
That is why F maps to 1111, A maps to 1010, and 0 maps to 0000 when you expand nibble by nibble. Programmers write the 0x prefix so a string of only digits is not mistaken for a decimal literal; this converter accepts the prefix when present and treats bare strings the same once digits are validated. Case does not matter: a, b, c, d, e, f and their uppercase forms are identical.
The minimal binary form drops leading zeros (except for the value zero itself), while the padded form keeps four bits per input hex digit so register dumps stay aligned on nibble boundaries. Classroom worksheets and CPU manuals use hex because a byte is two hex digits and a thirty-two-bit word is eight. Converting by hand is error-prone past a few places; a deterministic nibble-and-place-value pass removes that risk while still showing the expansion for short inputs so learners can audit the bit mapping.
If any character is not a hex digit after the optional prefix is removed, conversion stops with an invalid hex digit error—there is no best-effort parsing that skips junk or invents bits.
What you can do with it
Homework checks for hex-to-bit mapping
Students paste short hex literals from worksheets and compare hand-written nibble maps and the final binary against a deterministic result before submitting.
Firmware and register bitfield dumps
Embedded pipelines turn 0x-prefixed register values from logs into bit strings for bitmasks, alerts, and documentation that shows each nibble aligned.
FAQ
What is hex to binary conversion?
It maps a base-16 digit string to an equivalent base-2 bit string. Because 16 is 2^4, each hex digit expands to exactly four bits (one nibble).
Do I need the 0x prefix?
No. The prefix is optional. Both FF and 0xFF convert to 11111111.
Is the hex to binary converter free?
The browser tool is free and runs locally.
Why does each hex digit become exactly four bits?
Because sixteen is two to the fourth power, one hex digit always holds four bits, called a nibble. That is why F is 1111, A is 1010 and 0 is 0000 when you expand digit by digit.
What is the difference between the short and the padded binary result?
The short result drops leading zeros, except for zero itself. The padded result keeps four bits for every hex digit you typed, so register dumps and bitmasks stay aligned on nibble boundaries.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/fmt/hex-binary \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"hex":"0xFF"}'const res = await fetch("https://api.kit.forhosting.com/fmt/hex-binary", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"hex": "0xFF"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/fmt/hex-binary",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"hex": "0xFF"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/fmt/hex-binary", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"hex":"0xFF"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"hex":"0xFF"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/fmt/hex-binary", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"hex": "0xFF"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "fmt.hex_binary",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_hex_digits | 64 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Invalid characters—letters outside A–F, spaces, underscores, or an empty 0x—raise a clear invalid_input error instead of a silent wrong bit string. Students checking homework, embedded engineers reading register dumps, and API clients normalizing memory addresses all need the same deterministic path: no network, no random seeds, no wall-clock dependence.
How to call the API and what comes back
The value may include a leading 0x or 0X; after that only characters zero through nine and A through F (any case) are allowed. Send a JSON body with one required string field hex (aliases value, text, n, and input). Absolute length is capped at sixty-four hex digits so Worker and browser responses stay bounded. On success the response echoes the trimmed input, sets hex to the uppercase digit string without prefix, hex_lower to the lowercase form, prefixed to a canonical 0x plus uppercase digits, had_prefix to whether the client sent 0x, binary to the minimal base-2 bit string without leading zeros (except for zero), binary_padded to the four-bits-per-digit expansion that preserves nibble alignment, base_from sixteen and base_to two, digit_count to the number of hex digits, bit_count to the length of the minimal binary string, message to a one-line English summary, and steps to an ordered list that records prefix handling, validation, nibble mapping, and the final binary. Failed validation—missing hex, empty digits after 0x, spaces or underscores, characters outside the hex alphabet, or more than sixty-four digits—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price. Prefer binary when you need a compact bit string for code, and binary_padded when you need fixed-width nibbles for teaching or bitfield diagrams.
Practical tips, limits, and related searches
Prefer sending a string even when the value looks numeric: bare numbers are accepted only when they are non-negative integers written with decimal digits zero through nine, which is a convenience for small dumps, not a second radix. Do not embed spaces, commas, or underscore separators; strip them in your client before calling if your source uses grouped nibbles. Sixty-four hex digits cover two hundred fifty-six-bit integers, which is enough for most wide machine words and truncated hash displays; longer strings are rejected rather than silently truncated. Prefer this capability when the source is already known to be hex and you only need the bit string; if you must convert to decimal as well, call the matching hex-to-decimal tool in a second step. When teaching, pair examples: 0xFF maps to 11111111, 0xA maps to 1010, and G or 0x yields invalid_input so students see the error path. This landing targets people searching for a hex to binary converter, hexadecimal to binary calculator, or base-16 to base-2 tool; it is not a color picker, not a hex-to-decimal converter (use that sibling when you need base-10 integers), and not a general arbitrary-base calculator with a from-base parameter. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when you fuzz invalid digits. Round-trip checks are easy: convert a known value such as 0xFF by hand or with another trusted library and confirm that binary matches 11111111, then confirm that changing one letter to an invalid character flips the response to invalid_input with a message that names the bad digit.
Integration use cases
Unit tests for parsers and serializers
Generate known-good hex→binary pairs plus deliberate invalid-digit cases so coding kata expected values stay stable across languages.
Technical questions
What happens on an invalid hex digit?
The API returns invalid_input and names the problem (for example an unexpected letter). Failed validation is never charged.
What is the difference between binary and binary_padded?
binary is the minimal bit string without leading zeros (except for zero itself). binary_padded keeps four bits for every hex digit so nibble alignment is preserved.