REST Countries

Flag CDN

Free global CDN for country flag images

REST Countries serves public domain country flag images from a free global CDN. Use stable HTTPS URLs for 254 flags in PNG, JPG, GIF, and SVG across 330+ edge nodes, with an average response time under 100ms and no account or API key required.

Coverage 254 country flags
Image URLs 11,684 free CDN variants
Edge network 330+ global edge nodes
Avg response <100ms served from cache
Formats 4 PNG, JPG, GIF, SVG
Raster sizes 5 w160 through w2560

How to generate CDN URLs

The generator below turns country, format, size, and shape choices into a stable CDN URL. Use it to confirm the exact image path before adding the flag to HTML, CSS, app data, or server responses.

1

Pick the flag

Select a country to start from its two-letter ISO code.

2

Choose the image

Choose PNG, JPG, GIF, or SVG, then set the raster width and shape when needed.

3

Copy the URL

Copy the generated HTTPS URL or use the matching HTML and CSS snippets below.

Generate a flag URL

Choose the country, file format, raster width, and shape you want. The preview, CDN URL, examples, and rows below update from those selections.

Drop-in snippets

Copy the current flag URL as an HTML image or CSS background. The snippets track the picker so the country name, class name, and CDN URL stay aligned.

HTML
<img src="https://flags.restcountries.com/v5/w320/ca.png" alt="Canada flag">
CSS
.flag-ca {
    background-image: url("https://flags.restcountries.com/v5/w320/ca.png");
    background-repeat: no-repeat;
    background-position: center center;
}

URL shapes

These rows show the URL patterns for the available shape options: the original raster image, square crop, wide crop, and SVG vector file.

Available raster sizes

Raster files are generated in five width buckets. Use smaller files for compact UI and higher widths when the flag needs to stay sharp in larger layouts or high-density displays. SVG does not use width buckets, so these rows stay on raster URLs.

How delivery works

Each image URL is built for CDN caching. Requests hit Cloudflare first, fall back to CloudFront when needed, and ultimately resolve to the same S3-backed source assets. Cached flag requests average under 100ms.

Delivery is cookie free and GDPR compliant. The CDN can be used anonymously, without a REST Countries account, and with no tracking added to flag requests.

1

Cloudflare edge

Visitors are routed to nearby Cloudflare edge nodes where cache rules keep flag assets hot.

2

CloudFront fallback

Cold or missed assets fall back to CloudFront, which itself runs across 750+ edge nodes.

3

S3 source

S3 remains the durable source and final fallback for the flag image objects.

Terms of Use

The public domain flag images can be used for personal and commercial projects. Attribution is not required, but we ask that public-facing uses link back to restcountries.com when practical.

We also ask, but do not require, that the source flag images are left unmodified. If you need a different size, file type, or shape, use the CDN variants where possible.

Help shape the Flag CDN

The CDN is meant to grow around real use cases. If you need another flag, a different aspect ratio, another size bucket, another file format, or a related image variant, tell REST Countries what would help.

We cannot promise every request will ship, but the roadmap is collaborative: practical requests make it easier to prioritize what gets added next.

Contact support