Skip to content
Hex Calculator

Bootstrap to Hex Converter

Look up the official hex code behind any Bootstrap 5 theme color name — primary, secondary, success, danger, warning, info, light, or dark.

Hex result
#0D6EFD
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.

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

Further reading: CSS Colors — W3Schools

How Bootstrap to Hex Conversion Works

Bootstrap 5 defines 8 theme color roles, each with one official hex value: primary (#0D6EFD), secondary (#6C757D), success (#198754), danger (#DC3545), warning (#FFC107), info (#0DCAF0), light (#F8F9FA), and dark (#212529). This tool looks up your input by name (case-insensitive) against that fixed set and returns the matching hex code.

Bootstrap to Hex Example, Step by Step

primary = #0D6EFD

primary = #0D6EFD

Input: "primary"

Lowercase and compare against 8 known role names
Match found: primary

Result: #0D6EFD
StepDescriptionResult
Take the input name"primary"input string
Normalize casinglowercase for comparison"primary"
Match against the 8 role namesexact string matchfound: primary
Return the hex valueprimary's official hex#0D6EFD

The lookup requires an exact name match (ignoring case) — there's no fuzzy matching, so 'primry' or 'main' won't resolve, even though they might mean the same thing to a person.

Where Bootstrap to Hex Actually Comes Up

Matching a Non-Bootstrap Design to Bootstrap Roles

When implementing a design outside Bootstrap but wanting consistent semantic colors, looking up the official hex for danger or success ensures your custom CSS matches Bootstrap's conventions.

danger -> #DC3545

Setting Up a Sass Variable Override

Before overriding $success or another theme variable, checking the current default value gives you a starting point to compare your new brand color against.

success -> #198754 (default)

Documenting a Project's Color Usage

Style guides that reference Bootstrap semantic roles still need the actual hex values written down for designers and developers working outside the Bootstrap codebase.

role name -> hex for documentation

Common Mistakes With Bootstrap to Hex

  • Typing a CSS class name like "btn-primary" instead of just the role name "primary".
  • Assuming Bootstrap 4 and Bootstrap 5 share the same hex values — several theme colors changed between versions.
  • Looking for extended palette shades (like primary-subtle or primary-emphasis) that aren't part of this base 8-color set.

Why Use This Calculator Instead of Checking the Docs

  • Covers all 8 official Bootstrap 5 theme roles in one lookup
  • Runs entirely in your browser — nothing you type gets sent anywhere
  • Matches case-insensitively, so any casing works
  • Faster than digging through Bootstrap's documentation or source Sass files

Limitations

  • Finds the closest match in a fixed swatch list using weighted color distance — this is an approximation, not an official conversion, since the underlying brand doesn't publish a public hex specification.

Frequently Asked Questions

Which Bootstrap color names does this tool support?

All 8 Bootstrap 5 theme roles: primary, secondary, success, danger, warning, info, light, and dark — the official set from getbootstrap.com.

Is the name lookup case-sensitive?

No — "primary", "Primary", and "PRIMARY" all resolve to the same hex value, #0D6EFD.

What happens if I misspell a color name?

The tool returns an error asking you to check the spelling, since it only matches exact Bootstrap role names, not partial or fuzzy text.

What's the hex code for Bootstrap's primary color?

#0D6EFD — Bootstrap 5's default primary blue.

Are these the same hex values across all Bootstrap 5 versions?

Yes, these are the current official Bootstrap 5 theme color values. Bootstrap 4 used a different palette (e.g. primary was #007BFF), so double-check your Bootstrap version if the numbers look off.

How do I override a Bootstrap theme color with a custom brand color?

Look up the current hex value for the role you're overriding, then use it as a reference point when setting your new Sass variable (like $primary) so you know exactly what you're replacing.

Why does my project show a different hex for "primary" than this tool?

Bootstrap's theme colors are fully customizable via Sass variables — if a project overrides $primary, its actual color will differ from the framework default this tool looks up.