How to Create a Dynamic shields.io Endpoint Badge
The shields.io endpoint route renders a badge from a JSON document you host that declares schemaVersion, label, message, and color.
Publish a JSON file matching the shields endpoint schema, then reference it via img.shields.io/endpoint?url=<your-json>. shields fetches your JSON and renders the badge from its fields.
Steps
- Generate a JSON file with
schemaVersion: 1,label,message, andcolor. - Host it at a stable public URL (raw file, Pages, or an API).
- Reference it with the endpoint route in your README.
The JSON shields fetches
badge.json
{
"schemaVersion": 1,
"label": "tests",
"message": "428 passing",
"color": "brightgreen"
}README markdown
README.md
Gotchas
- The endpoint URL must be publicly reachable over HTTPS; private URLs return an error badge.
- Keep
messageshort; shields renders the raw string with no formatting.
Related guides
How to Create a Custom Badge from a GistCreate a custom badge whose value your CI updates by writing shields endpoint JSON to a gist with schneegans/…
How to Build a Badge for a Custom MetricBuild a badge that reflects a custom metric such as bundle size by computing the value in CI, writing shields…
How to Run a Self-Hosted shields.io ServerRun a self-hosted shields.io badge server with the official Docker image for private repos or rate-limit cont…