The short answer: 1600 × 900, a 16:9 ratio. That is the shape that fills a post on X without cropping, and it is the one to use unless you have a reason not to.

Why 16:9

X crops aggressively in the timeline, and 16:9 is the shape that fills a post card without cropping on either desktop or mobile. For code that matters more than it does for photos, because a crop that eats the last few characters of a line makes the snippet wrong rather than just badly framed.

The settings

In Codeshot, under Aspect Ratio, switch from Original to Fixed and pick the 16:9 shortcut. Then set the width to 800 and export at .

That gives you exactly 1600 × 900. 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
1:1 1080 × 1080 the snippet is short and squarish
4:5 1080 × 1350 you want maximum height in a mobile feed

Each is the same three settings: the ratio, a width, and a 2× export.

The mistake to avoid

Posting a tall screenshot of a whole file. X shows a cropped preview in the timeline, so the part people see is the middle of your code with the interesting bit cut off. Trim to ten or fifteen lines and let the ratio do the rest.

One more thing

Keep the file under 5 MB. A 2× PNG of a code snippet is nowhere near that, so this only bites if you are exporting at 3× with a photographic backdrop.

Sizes for other platforms

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.