The short answer: 1080 × 1080, a 1:1 ratio. That is the shape that fills a post on Facebook without cropping, and it is the one to use unless you have a reason not to.
Why 1:1
Square and 4:5 both perform well in the Facebook feed. The 1.91:1 shape only matters when your image is being used as a link preview, where it matches what Facebook generates from Open Graph tags.
The settings
In Codeshot, under Aspect Ratio, switch from Original to Fixed and pick the 1:1 shortcut. Then set the width to 540 and export at 2×.
That gives you exactly 1080 × 1080. Exporting at 2× rather than 1× is what keeps small text sharp on a retina display — a 1× export of a code snippet always looks slightly soft.
Other sizes that work
| Ratio | Pixels | Use it when |
|---|---|---|
| 4:5 | 1080 × 1350 | the snippet is tall |
| 1.91:1 | 1200 × 628 | the image is a link preview rather than a post |
Each is the same three settings: the ratio, a width, and a 2× export.
The mistake to avoid
Reusing a link-preview-shaped image as a normal post. At 1.91:1 a code snippet becomes a thin band, and Facebook will letterbox it in the feed.
One more thing
1.91:1 is not one of the ratio shortcuts, so type 1.91 and 1 into the width and height fields directly.
Sizes for other platforms
- X (Twitter) — 1600 × 900 at 16:9
- LinkedIn — 1080 × 1080 at 1:1
- Instagram — 1080 × 1080 at 1:1
See all articles for the rest, including the other platforms.
Whichever platform you post to, the theme matters as much as the size once the image is scaled down. You can compare all 30 before you pick one.