Skip to content

Instantly share code, notes, and snippets.

@sugatoray
Last active February 27, 2021 18:44
Show Gist options
  • Save sugatoray/f8e7a0f67554f10944a10335b05d96b3 to your computer and use it in GitHub Desktop.
Save sugatoray/f8e7a0f67554f10944a10335b05d96b3 to your computer and use it in GitHub Desktop.
How to share code on social media using images

Sharing code on social media using images

You must have often seen people sharing code in beautiful images.

  • How can you do the same without much effort?
  • Does there exist any service where you could just copy and paste your code and create such images?

YES 💡 🔥 ⚡ https://carbon.now.sh aka Carbon.

You can go to Carbon and just paste your code in the editor and download a beautiful image (svg or png). The following example was created on Carbon.

Python demo
A demo python class - by Author

Reproducible Configuration for Carbon

You can also use a carbon-config.json file to import/export the configuration you used on Carbon while creating the code images.

// https://carbon.now.sh/
// carbon-config.json

{
    "paddingVertical": "56px",
    "paddingHorizontal": "56px",
    "backgroundImage": null,
    "backgroundImageSelection": null,
    "backgroundMode": "color",
    "backgroundColor": "rgba(74,144,226,1)",
    "dropShadow": true,
    "dropShadowOffsetY": "20px",
    "dropShadowBlurRadius": "68px",
    "theme": "material",
    "windowTheme": "none",
    "language": "auto",
    "fontFamily": "Fira Code",
    "fontSize": "14px",
    "lineHeight": "152%",
    "windowControls": true,
    "widthAdjustment": true,
    "lineNumbers": true,
    "firstLineNumber": 1,
    "exportSize": "2x",
    "watermark": false,
    "squaredImage": false,
    "hiddenCharacters": false,
    "name": "",
    "width": 680
}

Other Options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment