DEV Community

with-heart
with-heart

Posted on • Updated on

How to scale Excalidraw diagrams for Twitter posts

I've been using Excalidraw to create diagrams that I use in Twitter threads. Unfortunately it's difficult to manually scale diagrams to the correct aspect ratio in Excalidraw.

I finally figured out a solution to this problem, at least for Twitter!

Here's how I did it:

  1. Save this frame image and then import it into Excalidraw (I usually drag the image file onto the canvas)
  2. For each diagram you want to use on Twitter, duplicate the frame and scale your content to fit within its border
  3. When you're ready to export, first set the opacity of the artboard to 0% and then select both the hidden artboard and the content
  4. Add your new image to your Twitter post!

This works because the size of the frame matches the maximum size of Twitter post images, so as long as your content fits in the frame, it will be sized to fit correctly in a Twitter post.


If you followed these steps correctly, here's what the export pane looks like in Excalidraw:

Export pane of Excalidraw showing a correctly sized image

If you followed the steps incorrectly, the export pane of Excalidraw will look like one of the following:

  • incorrectly scaled: be sure to select the artboard and the content before exporting

Excalidraw export that is incorrectly scaled because the artboard wasn't selected

  • black border is in the image: be sure to set the artboard's opacity to 0% before selecting it and the contents for export

Excalidraw export with the border in the image


You can see the difference in scaling between the first post (correct; using this method) and the second post (incorrect; exporting the content directly):

Excalidraw image that is correctly sized to fit within a Twitter post

Excalidraw image that is not correctly sized to fit within a Twitter post so the sides of the image are cut off

Top comments (0)