Hex to Unary Converter

Parses a hexadecimal number and outputs a chosen symbol (default "1") repeated that many times, the simplest possible number representation, capped at 100,000 repetitions to keep the output from becoming unmanageable. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Unary is the most primitive way to represent a number: no digits, no place value, just a symbol repeated once per unit. It's rarely practical, but it's a staple of computability theory and a fun way to visualize just how much more compact positional notations like hex really are.

This tool takes a hex number and expands it into that many repetitions of a symbol you choose, entirely in your browser.

What Is Hex to Unary Converter?

A converter that reads a hexadecimal number and writes out a chosen unary symbol (by default "1") repeated once for every unit of the value it represents.

Because unary has no positional structure, the length of the output is the value itself, which is also why this tool enforces a cap: without one, a modest-looking hex input could otherwise generate an astronomically long string.

How Hex to Unary Converter Works

The input is parsed as hexadecimal (with an optional 0x prefix, case-insensitive digits), converted to an exact integer using JavaScript's BigInt so no precision is lost even for large values, then checked against the 100,000 cap.

If the value is within the cap, the chosen symbol string is repeated exactly that many times using JavaScript's native String.prototype.repeat and returned as the output.

When To Use Hex to Unary Converter

Use it for teaching or demonstrating what unary notation actually looks like next to a compact positional system like hex, or for generating a fixed-length repeated-symbol string from a hex-encoded count.

It's also handy for quick sanity checks in computability or automata theory exercises where unary-encoded inputs are the expected format.

Features

Advantages

  • Produces an exact unary expansion with no precision loss, even for the largest values the cap allows.
  • Lets you pick any repeated symbol, not just "1", useful for tally-mark or custom-symbol demonstrations.
  • Runs entirely client-side with no network round trip.

Limitations

  • Capped at 100,000 to avoid generating unreasonably large strings; larger hex values are rejected outright.
  • Negative hex values are rejected since unary notation has no standard way to represent a sign.
  • Not useful for any real arithmetic; unary has no positional value, so it's purely illustrative or theoretical.

Examples

Converting a small hex value

Input

5

Output

11111

Hex 5 equals decimal 5, so the default "1" symbol is repeated five times.

Converting hex with a 0x prefix and a custom symbol

Input

0xA (symbol: *)

Output

**********

Hex A equals decimal 10, so the chosen "*" symbol is repeated ten times.

Best Practices & Notes

Best Practices

  • Use small hex values for anything you intend to actually read; unary output is only practical for illustrating the concept, not for large numbers.
  • If you need a large value's unary length for a script rather than to eyeball it, consider just computing the length (the decimal value) instead of generating the full string.

Developer Notes

Parsing reuses this category's shared hex-string parser (case-insensitive digits, optional 0x prefix, optional sign for rejection) and converts to BigInt before comparing against the 100,000 cap, so the cap check itself never risks floating-point rounding on huge inputs.

Hex to Unary Converter Use Cases

  • Teaching or visually demonstrating unary notation next to hexadecimal
  • Generating a fixed-count repeated-symbol string from a hex-encoded count
  • Producing unary-encoded test input for computability/automata exercises

Common Mistakes

  • Expecting large hex values to convert; the 100,000 cap exists specifically to prevent multi-megabyte output.
  • Assuming unary supports negative numbers; there's no standard unary encoding for a sign, so negative input is rejected.
  • Forgetting that hex 0 correctly produces an empty string, not an error.

Tips

  • Pair this with Unary to Hex Converter to convert a unary count back into a compact hex value.
  • Use a distinctive custom symbol (like "*" or "|") when you want the repetition to be easy to visually count.

References

Frequently Asked Questions