JSON Canvas Viewer: A frontend library to render Obsidian canvas in websites

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.

An interactive demo is right here:

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

Motivation Behind It

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.

Features

  • 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)

Zero-Setup 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>

Full Version

I strongly recommend this version since it embraces modern tooling and has better performance compared with the CDN-shipped version. It requires careful setup of the bundler and framework. Access more detail here.

You Can:

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

2 Likes

: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.

is it possible to use a gitlab runner to create gitlab pages that show the obsidian canvas?

Yes, JSON Canvas Viewer is simply a frontend library that is used in your website. You can build the website inside the GitLab runner and deploy to GitLab pages.