Hex Digit Duplicator

Duplicates each digit of a hexadecimal value N times in place (default N = 2), turning "1A" into "11AA", useful for expanding shorthand color codes and other repeated-digit encodings. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Some hex-based shorthand notations, most notably CSS's 3-digit hex colors, rely on each digit being implicitly duplicated to reach a full-length value, and manually expanding that by hand is easy to get wrong on longer values.

This tool duplicates every digit of a hex value a chosen number of times in place, giving you the expanded value instantly.

What Is Hex Digit Duplicator?

A text-manipulation tool that repeats each hex digit in a value N times, preserving digit order, with N defaulting to 2.

It's the reverse of "compression by shorthand": wherever a format assumes each digit stands in for several repeated ones, this tool performs that expansion explicitly.

How Hex Digit Duplicator Works

The input is validated as hex digits (an optional 0x prefix is stripped), and the repeat count N is checked to be a whole number from 1 up to the tool's cap of 50.

Each digit in the validated value is repeated N times in place (using string repeat), and the repeated digits are joined back together in original order to form the output.

When To Use Hex Digit Duplicator

Use it to expand a 3-digit CSS hex color shorthand into its full 6-digit form by duplicating each digit once (N = 2).

It's also useful any time you need to stretch a short hex code into a longer one following a simple repeat-each-digit rule, rather than typing the expansion out by hand.

Often used alongside Hex Digit Extractor and Hex Number Joiner.

Features

Advantages

  • Handles any length of input, not just the 3-digit CSS color case.
  • Lets you choose N explicitly rather than assuming a fixed doubling.
  • Instant, deterministic, fully client-side.

Limitations

  • N is capped at 50 to avoid generating excessively long output from a long input.
  • Assumes every digit should be duplicated equally; it can't apply a different repeat count to different digits within the same run.

Examples

Expanding a CSS-style shorthand color

Input

1A (N = 2)

Output

11AA

Each digit is duplicated twice in place: 1 → 11, A → AA.

Tripling each digit

Input

F0 (N = 3)

Output

FFF000

Each digit is repeated 3 times in place: F → FFF, 0 → 000.

Best Practices & Notes

Best Practices

  • Use N = 2 specifically when expanding CSS 3-digit hex color shorthand, since that's the doubling that format's spec defines.
  • Keep N reasonable for your use case; very large N values quickly produce output that's unwieldy to read or paste elsewhere.

Developer Notes

Implemented with String.prototype.repeat() per validated digit, capped at N = 50 to keep worst-case output size bounded; validation happens before any duplication so an invalid character never silently ends up repeated in the output.

Hex Digit Duplicator Use Cases

  • Expanding a CSS 3-digit hex color shorthand (#ABC) into its full 6-digit form (#AABBCC)
  • Stretching a short hex code into a longer one for a fixed-width field or test fixture
  • Demonstrating repeat-each-digit encodings for teaching or documentation purposes

Common Mistakes

  • Forgetting the # prefix isn't hex and needs to be added back manually after expanding a CSS color's digits.
  • Assuming N = 2 always means "double the string length"; it duplicates each digit N times, which for N = 2 does double the length, but that's specific to N = 2.

Tips

  • For CSS colors, feed in just the 3 (or 4, with alpha) digits after the #, then re-add the # to the duplicated output yourself.
  • Combine with the Hex Digit Extractor if you need to spot-check one digit of the expanded result.

References

Frequently Asked Questions