The short answer: 1080 × 1080, a 1:1 ratio. That is the shape that fills a post on Instagram without cropping, and it is the one to use unless you have a reason not to.
Why 1:1
Instagram is the hardest place to share code, because the audience is not there to read and the feed is entirely mobile. Square keeps text as large as possible in a small frame; 4:5 buys extra height for a slightly longer snippet.
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 | you want the largest feed footprint |
| 9:16 | 1080 × 1920 | posting to Stories or Reels |
Each is the same three settings: the ratio, a width, and a 2× export.
The mistake to avoid
Posting more than about eight lines. On Instagram the snippet has to be legible at thumbnail scale, which is a much harder constraint than anywhere else. Fewer lines and a larger font beats a complete example nobody can read.
One more thing
Stories and Reels are 9:16, which is a ratio shortcut. Leave generous margins so nothing important sits under the interface overlays.
Sizes for other platforms
- X (Twitter) — 1600 × 900 at 16:9
- LinkedIn — 1080 × 1080 at 1:1
- Facebook — 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.