Add Copy button to code fence

Hi, would it be possible to add a small button on the code fence that would copy whatever is inside the fence?

It would be a nice feature to have.


I would see this more as a plugin, but it’s still sounds useful!

1 Like

I second this, very useful for storing code snippets in notes.

It is easy to implement. Here is an example and also the implementation:

I fully agree! This would be a great feature to have! It’s one of the little things I am really missing at the moment. I have a lot of code snippets that I have to copy every day.
Such a feature would be very comfortable and would make the note-taking flow
even more fluent.

I would propose the following behaviours:

  • A simple click on the code block will copy it’s content to the clipboard
  • A click on a small icon in the upper right corner will do the same

A possible UI implementation could look like this:

Keep up the great work!


I agree with this option as well, coming from Bear I have become used to Right Click > Copy Code Block A button in the top right would be an improvement over Bear.

I generally use an autocorrect/text expander for anything likely to be used regularly. Can be used in any program, needs no mouse and fast.

This would be a great feature to have! I use Obsidian daily as reference for code and CLI things so a copy option would be welcome!


Any news on this request here? I am missing this little tiny feature every day. May it would make it on one of the next release roadmaps? Pleeeeeeeaaaase! :pray:


Hey all,

I just added a plug-in for this, just search for code block copy.

Code is here:

Let me know if there are suggestions to improve it.


I just tried it, this is awesome!

Thank you!

@danbburg I have tried your plugin right now :smiling_face_with_three_hearts: It works fantastic! This should be implemented as an integral part of Obsidian! It’s so useful!
Thank you very much for this contribution! :clap: :clap: :clap: :clap: :clap: :clap: :clap:

Really awesome! Thanks for this.