Share Your Obsidian Canvases Anywhere: I Developed a Viewer Library

Have you ever wished you could share your .canvas files beyond the app? Embed them in blogs or documentation sites without losing interactivity? I built a library for this:

JSON Canvas Viewer
An embeddable, highly customizable, and, framework-agnostic library to render Obsidian Canvas files anywhere on the web.

Tip: Obsidian Canvas is also called JSON Canvas.

An interactive demo is right here:

https://hesprs.github.io/json-canvas-viewer

:confused: Sorry to include a link here, but I think it is necessary since you may not be able to find this project elsewhere. It’s a pure development showcase without any commercial purpose.

You can also find everything in the page above - including GitHub repo, documentation, npm page, and more about JSON Canvas.

:high_voltage: Motivation Behind It

Obsidian’s Canvas is brilliant—but trapped in the app. When I wanted to showcase my canvases on my website, I hit a wall. Existing solutions were either buggy, uncompleted, or locked to specific frameworks. So I built JSON Canvas Viewer to solve this.

:rainbow: Features & Advantages

  • TypeScript native
  • Can display 100% of canvas features described in the official spec
  • Responsive design with robust mobile and touchpad support
  • Supports lazy loading / prerendering
  • Out-of-the-box extensibility and tree-shaking, four optional modules are available
  • Truly universal: it provides Vite plugin, React Component, Vue Component, and Vanilla JS class
  • A chimp version specially designed for fast trial is available
  • Included in JSON Canvas official website (see Apps and tools - Libraries - TypeScript viewer library)

Try it in 5 seconds (chimp version):

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
	<title>šŸ’ Canvas Viewer</title>
	<style>
		body,
		html {
			margin: 0;
			padding: 0;
			width: 100%;
			height: 100%;
		}
	</style>
</head>
<body></body>
<script type="module">
import { JSONCanvasViewer, parser, loadCanvas } from 'https://unpkg.com/json-canvas-viewer/dist/chimp.js';
new JSONCanvasViewer({
    container: document.body, // The element to attach the viewer to
    canvas: loadCanvas('path/to/your.canvas'),  // remember to prepare your canvas
    markdownParser: parser,
});
</script>
</html>

You Can:

:star: Star the repo: json-canvas-viewer
:bug: Try it with your complex canvases and report issues.
:light_bulb: Suggest features - like supporting Advanced Canvas (from Developer-Mike) features.
:handshake: Contribute to it if you have passion!

2 Likes

Notice: sorry for the confusion, the demo link has been moved to another location.

The new demo is available at (you can find the link to the GitHub repo inside):

Compared with the time that I created this post, JSON Canvas Viewer has been improved a lot, including a release a major version v4. Improvements including better visual appearance, smooth interaction, performance optimizations, reloading support, replace canvas nodes with custom React/Preact/Vue components, and much more.

If you feel interested, welcome to comment below. You can give me a star to support my work!

:loudspeaker: Finding a Reposter!

I have an additional request if you find my work is valuable: I need a helpful person to repost JSON Canvas Viewer to Reddit, specifically r/ObsidianMD.

The reason is that my Reddit account is shadow-banned (it thinks I changed my IP too frequently), so I’m not capable to post or reply anything.

If you are wiling to help me, please send a private message to me (click my avatar > Message), I will tell you what and how to post. Please don’t post without notifying me since I’m afraid of your account being shadow-banned as well.

If a reposter has been found and the post has been made. I will make a new reply in this thread to clarify that.