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

  1. Copy your code to the clipboard (⌘ - command + C).
  2. Open Codeshot.
  3. Paste the code into Codeshot (Edit > Paste Code, or ⌘ - command + ⇧ - SHIFT + V). The language is detected for you.
  4. Pick the theme you want, and a light or dark variant.
  5. Choose a backdrop — a macOS wallpaper, a gradient, a solid colour, or your own image.
  6. Under Aspect Ratio, switch from Original to Fixed and pick a ratio. 16:9 suits a tweet well.
  7. 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.