How to Put Fully Interactive, Runnable Code in a Medium Post

Code is meant to be interactive.

  1. Head to repl.it
  2. Write some code in your favorite language.
  3. Copy and paste the url for your repl into a Medium post.
  4. Publish the post to make the code interactive.

Interactive code. In a Medium article! (from repl.it).

Feel free to play around with the code above. This is a simple example, but you can create complex scripts for readers to run in many languages.

Notes

  • The code is only fully interactive after you publish
  • You can add packages, data files, or include multiple scripts in your repl
  • This does work on mobile although not perfectly
  • Each time the page is reloaded, the packages are installed

Besides embedding code in your articles, repl.it has a great discussion forum and interactive exercises to learn coding.


I welcome comments, feedback, or constructive criticism and can be reached on Twitter @koehrsen_will.