The GitHub Social Preview size (1280×640px)
The GitHub Social Preview size is 1280×640 pixels (2:1 aspect ratio). Upload your image above and Pixohub resizes it to exactly that, in your browser.
GitHub lets you set a social preview image on a repository, and it recommends 1280x640 pixels at a 2:1 ratio for the best display. This is the card that appears when someone shares your repo link on X, Slack, Discord, LinkedIn, or in a chat, so instead of the basic repository details and owner avatar GitHub shows by default, your project gets a branded card with its name, logo, or a tagline.
The 2:1 shape is close to the roughly 1.91:1 card most link previews use, so only a thin strip is trimmed on those platforms. GitHub requires the image to be a PNG, JPG or GIF under 1 MB, and that limit matters more than the pixel count: a photographic 1280x640 PNG is usually over it, while a JPG of the same card is not.
Because a preview card is scanned quickly in a busy feed or channel, keep it simple and legible: the repository or project name large, maybe a short tagline and a logo, with strong contrast and comfortable margins so nothing important sits where a platform might crop or overlay it. Consistent preview cards across your projects make an organization's repos feel like a coherent product family. GitHub can change its preview handling, so verify the current recommendation before setting it.
Official GitHub social preview specs
GitHub Docs state that a repository's social preview image should be a PNG, JPG or GIF under 1 MB, at least 640 × 320 px for good quality and 1280 × 640 px for the best display. The image is uploaded in the repository's Settings page under Social preview and replaces the card GitHub would otherwise generate automatically.
Until you add an image, GitHub's docs say repository links expand to show basic information about the repository and the owner's avatar. A custom card is worth it mainly when you want branding, a screenshot of the product or a clearer one-line pitch. You can upload one to any public repository, or to a private one that already had an image.
| Spec | Value |
|---|---|
| Recommended | 1280 × 640 px (2:1) |
| Minimum for good quality | 640 × 320 px |
| Formats | PNG, JPG, GIF |
| File size limit | Under 1 MB |
| Where to set it | Repository → Settings → Social preview → Edit |
Last updated · Source: GitHub Docs
What 1280×640 does to a real photo
GitHub's 1 MB cap decides the format here. As PNG, the 1280 × 640 card was 1.6 MB from the landscape photo and 2.0 MB from the portrait: both too big to upload. The JPG option produced 157 KB and 264 KB, well inside the limit. For any photo or screenshot, download JPG; a PNG only stays under 1 MB when the card is flat colour and text.
The 2:1 crop kept 67% of the landscape photo but only 38% of the portrait, so a portrait source needs its subject in the middle band of the frame.
We ran this page on two iPhone photos from our test set, one landscape and one portrait, with the default settings (crop to fill), then saved the same result as a JPG at 85% quality.
| Photo | Original | Kept after crop | PNG result | JPG result |
|---|---|---|---|---|
| Portrait iPhone photo | 3024 × 4032, 4.7 MB | 38% | 2.0 MB | 264 KB |
| Landscape iPhone photo | 4032 × 3024, 1.4 MB | 67% | 1.6 MB | 157 KB |
Last updated
What GitHub says about uploads
From GitHub's own help and developer pages, checked 24 October 2026. Each point links to the page it comes from.
What happens after upload
- Transparent PNGs are supported, but they may look different on dark-mode or non-transparent platforms; GitHub suggests a solid background if unsure. docs.github.com
Upload limits
- Social preview: PNG, JPG or GIF under 1 MB; at least 640 x 320 px, 1280 x 640 px for best display. docs.github.com
Why 1280×640 pixels?
2:1 is close to the 1.91:1 that Facebook and LinkedIn use for link cards, so only a thin strip is trimmed there. 1280 px is the width GitHub names for the best display, and it leaves headroom for text to stay crisp on high-DPI laptops.
The 1 MB cap is the real constraint, not the pixel count. Gradients, shadows and photographic backgrounds are what push a lossless file over it, so design the card with that limit in mind.
Common upload problems and how to fix them
GitHub rejects the upload as too large
The file is over 1 MB. PNG keeps every pixel losslessly, which is heavy for screenshots and photos. Fix: switch the download to JPG (smaller) before saving; if a flat PNG is still over, run it through Compress Image.
Shared links still show the old automatic card
Social platforms cached the preview before you uploaded the image. Fix: re-scrape the repository URL with Facebook's Sharing Debugger or LinkedIn's Post Inspector; Slack and Discord pick up the change for new shares after their caches expire.
Transparent background looks wrong in dark mode
A transparent PNG is placed on whatever background each site uses — white on one, near-black on another — so dark text or a dark logo can vanish. Fix: GitHub itself suggests a solid background if you are unsure; add one before resizing.
The project name is cut off on some sites
Platforms that use 1.91:1 trim a little from the top and bottom, and some overlay the domain in a corner. Fix: keep the name and logo at least 60 px from every edge of the 1280 × 640 canvas.
More things to know about GitHub
- GitHub accepts PNG, JPG or GIF here; a GIF is only worth it if the card is a simple flat graphic.
- Organisations can keep a consistent template (same background, logo position, font) and swap only the repository name for each project.
- A short tagline that says what the project does beats a long feature list — the card is usually seen at a few hundred pixels wide.
- Screenshots of a terminal or UI read better when cropped tight to the interesting part than when the whole window is shrunk into the card.