You might come across a tweet with a code snippet image like this and wonder how they did it.

Generate an image from a code snippet like this is very easy with Codeshot.
How to generate code snippet image
- Copy your code to the clipboard (⌘ - command + C).
- Open Codeshot.
- Paste the code into Codeshot (Edit > Paste Code, or ⌘ - command + ⇧ - SHIFT + V). The language is detected for you.
- Pick the theme you want, and a light or dark variant.
- Choose a backdrop — a macOS wallpaper, a gradient, a solid colour, or your own image.
- Under Aspect Ratio, switch from Original to Fixed and pick a ratio. 16:9 suits a tweet well.
- Export with File > Save Image (⌘ - command + S), or copy the image straight to the clipboard with ⌘ - command + ⇧ - SHIFT + C.
That's it. You will get a perfectly aligned code image for your tweet.
