[][src]Crate badge_maker


A fast and accurate badge maker for services like shields.io. Verified to match badge-maker 1-to-1 with side by rendering tests*.

example: flatexampleflat

example: plasticexampleplastic

example: flatsquareexampleflatsquare

badge: makerbadgemaker

color: examplecolorexample

example: badgeexamplebadge

*This library differs in that it generates unique IDs for the svg so it can be directly embedded in websites (such as in this doc_svgs). So a diff between the outputs will not match. We only claim the visual outputs match which is whats important.


This library is meant to be the Rust version of badge-maker. The use cases for this library are two-fold:

  • Rusty badge maker for any rust-based shields.io clones
  • WASM based npm package for a speed increase over the node based version (numbers coming when optimizations are finished)

Current todos

  1. Better code coverage
  2. Optimize text formatters
  3. Fix errors. The output is ugly.
  4. Other badge styles (requires a custom renderer)


badge: makerbadgemaker

use badge_maker::BadgeBuilder;

let svg = BadgeBuilder::new()

println!("{}", svg);


This library is still in its infancy. Tests and documentation are being added whenever possible. If you are interested in contributing then check out the repository. The API is likely to change. If you see something you think would work better than the way I've done it open an issue, I'd love to hear your suggestions.

We support different styles, colors, logos, and links. The badge builder accepts all of these options with the field() and an alternate method of field_parse() which accepts a string and will attempt parse the text as a valid field.


This is a library but you can use it with a simple cli tool as well.

example: badgeexamplebadge


cargo install badge-maker --features cli


badge-maker example badge -c informational -l #282828 -s flat


We currently support hex colors 3 and 6 chars long, named colors and their alias's, and RGB color inputs. These can be constructed with their enum variants or using the ...parse() methods.

color: examplecolorexample

use badge_maker::BadgeBuilder;
use badge_maker::color::{Color, AliasColor, NamedColor};

let svg = BadgeBuilder::new()
    // by enums
    .color(Color::Rgb(10, 200, 50))
    // or parsing
    .color_parse("rgb(10, 200, 50)")


Supported. Others coming soon. See Style enum for choices when building or use the string literals.

  • Flat example: flatexampleflat
  • Plastic example: plasticexampleplastic
  • FlatSquare example: flatsquareexampleflatsquare
  • ForTheBadge
  • Social
use badge_maker::{BadgeBuilder, Style};

let svg = BadgeBuilder::new()
  .style(Style::Plastic) // example of using typed input
  .style_parse("plastic") // example of parsing to derive

println!("{}", svg);

Adding links to the natively rendered badge supported. This is great if you need to embed the svg directly. However, on a website like the rust docs they may show the underline. To solve this, your third-party api that renders the badges should wrap the svg in markdown [![name for readers](link to api endpoint)](link when clicked).


use badge_maker::BadgeBuilder;

let logo_url = "https://upload.wikimedia.org/wikipedia/commons/\

let svg = BadgeBuilder::new()





Badges are valid and have all the necessary fields to construct an SVG without error. Use the BadgeBuilder to construct.


Constructs a Badge with given options. Message is the only required field.




Used to define the style of a badge. Used in BadgeBuilder.style()