Skip to content
Hex Calculator

Tailwind to Hex Converter

Convert a Tailwind arbitrary value class like bg-[#2563EB] back into a plain 6-digit hex color code you can paste into any design tool or CSS file.

Hex result
#225566
Swapnil Sanghvi

Built by

Swapnil Sanghvi

Full-Stack Web Developer & WordPress Developer

Swapnil Sanghvi is a full-stack web and WordPress developer, UI designer, and full-time freelancer who builds and maintains Hex Calculator.

Tailwind to Hex Converter tool preview card from Hex Calculator
Share preview: this is the card that appears when you share the Tailwind to Hex Converter page on social media.

Further reading: CSS Colors — W3Schools

How Tailwind to Hex Conversion Works

A Tailwind arbitrary value class like bg-[#2563EB] contains the raw CSS value inside square brackets. This tool extracts that value and returns the plain 6-digit hex code, #2563EB — it also accepts a bare hex code with no class wrapper at all.

Tailwind to Hex Example, Step by Step

bg-[#2563EB] = #2563EB

bg-[#2563EB] (Tailwind) = #2563EB (hex)

Class: bg-[#2563EB]

Strip the prefix: [#2563EB]

Strip the brackets: #2563EB
StepDescriptionResult
Take the Tailwind classbg-[#2563EB]bg-[#2563EB]
Locate the bracketed valuecontent between [ and ]#2563EB
Return the hex codealready includes ##2563EB

The utility prefix (bg-, text-, border-, ...) is ignored entirely — only the bracketed value matters for extracting the color.

Where Tailwind to Hex Actually Comes Up

Extracting a Color From a Handed-Off Component

When you receive a className with an arbitrary value class and need the actual color for a spec, a different tool, or another codebase, this pulls it out directly.

bg-[#2563EB] -> #2563EB

Auditing Colors Used Across a Codebase

Compiling a list of every hex value hiding inside arbitrary value classes helps identify inconsistent or redundant colors before consolidating them into a proper design token.

scattered classes -> color audit list

Migrating a Project Away From Tailwind

Rebuilding a design in plain CSS or another framework needs the raw hex values, not the Tailwind class names — this extracts them one class at a time.

Tailwind class -> raw hex for migration

Common Mistakes With Tailwind to Hex

  • Pasting a named palette class like bg-blue-600, which has no hex value embedded in the class name itself.
  • Including surrounding quotes from a className string, which aren't part of the class name.
  • Assuming the prefix (bg-, text-, ...) changes the extracted hex value — it doesn't, only the brackets matter.

Why Use This Calculator Instead of Extracting It by Hand

  • Works with any color-accepting utility prefix, not just bg-
  • Runs entirely in your browser — nothing you type gets sent anywhere
  • Also accepts a bare hex code with no class wrapper
  • Strips stray quotes and whitespace automatically

Limitations

  • Reads the exact hex value out of Tailwind's arbitrary-value syntax (bg-[#RRGGBB]) — it doesn't resolve named Tailwind palette classes like bg-blue-600 back to a hex value.

Frequently Asked Questions

How does this tool extract hex from a Tailwind class?

It reads the value inside the square brackets of an arbitrary value class like bg-[#2563EB] and returns just the hex code, #2563EB.

Does it work with any utility prefix?

Yes — bg-[#2563EB], text-[#2563EB], border-[#2563EB], and similar prefixed arbitrary value classes all extract the same hex code.

What if I paste a bare hex code instead of a full class?

It's also accepted directly — if there are no brackets to extract from, the tool treats the input as a hex code and normalizes it.

Does this work with named Tailwind colors like bg-blue-600?

No — named palette classes like blue-600 aren't hex values themselves, they resolve to a hex value through Tailwind's config, so there's nothing to extract directly from the class name.

Why would I need to reverse a Tailwind class back to hex?

It's useful when you're handed a component's className and need the underlying color value for a design spec, a different codebase, or a non-Tailwind tool.

How do I document colors used across a Tailwind codebase?

Extract the hex value from each arbitrary value class you find and compile them into a reference list — a quick way to audit what actual colors a project uses beyond its named palette.

Can I use this to migrate a Tailwind project to plain CSS?

Yes — pulling the hex value out of each arbitrary value class gives you the raw colors needed to rebuild the same visual design with standard CSS custom properties instead of Tailwind utilities.