Skip to content

Building Extensions ​

An extension adds something to Typora: a code-block language that draws a diagram, a view in the detail panel, a viewer for a file type, TeX macros, templates, commands, and more. One extension package runs unchanged on macOS, Windows and Linux.

Most extensions need no code at all. A JSON manifest is enough to add Kroki diagrams, issue links, task lists, input rules or snippets. When you need custom rendering you add an HTML page; when you need logic you add a script that runs in a Worker.

Trust tiers ​

Everything an extension contributes belongs to one of three tiers. The tier decides where it runs and what it can reach.

TierWhat it isRuns inCan reach
L0 — dataJSON in the manifest, Markdown templates and snippets, TeX macrosInterpreted by TyporaNothing — Typora applies it
L1 — pagesHTML / JS / WASM pages: fence renderers, detail views, file viewersA sandboxed frame with its own originOnly the messages Typora sends it, and the View SDK
L2 — logicA main script (one per window) and/or a background script (one per app)A locked-down Worker per extensionOnly the Worker API, filtered by permissions

Rules that hold for every tier:

  1. A Markdown document is data. Fence bodies, inline text and front matter are passed to your extension as input. Opening a file never runs code.
  2. No extension code runs inside the editor. Pages run in sandboxed frames, scripts run in Workers. Neither can touch the editor's DOM or internal state.
  3. No network, storage or file access by default. Pages and Workers have connect-src 'none'. Network, storage and clipboard go through Typora and are limited to what the user granted.
  4. Everything is disposable. All contributions are removed when an extension is disabled, uninstalled or reloaded.

There is no "full trust" mode: no shell commands, no arbitrary file system access, no Node.js.

What a package looks like ​

An extension is a folder named after its id, with a typora-extension.json manifest at the top:

yourname.hello/
  typora-extension.json     manifest (required)
  main.js                   L2 script, optional
  renderer.html             L1 page, optional
  snippets/                 L0 files, optional

Installed extensions live in ~/.config/Typora/Extensions/<id>/ (inside the app's container in sandboxed macOS builds). Users install them from the store, from a folder or a .typora-extension file in Settings ▸ Extensions.

Where to go next ​

Theme adapted from Nimbus (MIT).