← All tools Observable Notebooks 2.0 export Archived

Archived 18 October 2026. Observable now does this itself. You can download a notebook's source as an Observable 2.0 .html file straight from observablehq.com, so this bookmarklet is no longer needed.

Observable Notebooks 2.0 export

A bookmarklet that downloads the source of any Observable Notebooks 2.0 notebook as a self-contained Observable 2.0 .html file. Useful for editing with Observable Desktop.

Overview

Observable ships each notebook's source inside the page as a Next.js data payload. This bookmarklet reads that payload, reconstructs the notebook, and serializes it back into the Observable 2.0 file format — a single <notebook> document with one <script> element per cell. The result is a portable file you can version-control, edit locally, or re-import.

The output is meant to match what Notebook Kit's own serialize() produces byte for byte, so Observable Desktop and notebooks build read it without complaint.

Everything runs client-side against the notebook you're viewing. Nothing is sent anywhere except a request back to observablehq.com for the page you're already on.

Specification

This section describes the tool's current behaviour in enough detail to rebuild it. Wording in quotes is the exact UI copy.

1. Platform and dependencies

2. Tool page layout

3. Copy source

4. Reading the notebook

When the bookmarklet runs:

  1. Host check. The page's hostname must be observablehq.com or a subdomain of it (so new.observablehq.com works too). Otherwise it fails with "Open a notebook on observablehq.com first."
  2. Re-fetch the page. It requests the current path and query string from the same origin (§6). It re-fetches on purpose: Observable navigates client-side, so after clicking through from a listing, the page's embedded data still describes the page you came from.
  3. Extract the Flight payload. From the fetched HTML it collects every self.__next_f.push([1, "…"]) call, JSON-decodes each string and joins them in order. If the fetch fails or finds nothing, it falls back to the live page's self.__next_f array (entries of the form [1, string]), then to the same regex over the live page's HTML. If all three are empty it fails with "Couldn't read Observable's page data. Reload the notebook and try again."
  4. Index the rows. The payload is React Flight rows of the form <hex id>:<value>, one per line. A T row (<id>:T<hex length>,<text>) holds a text blob whose length is a UTF-8 byte count, so it may contain newlines.
  5. Resolve references. A string value of $<hex>, $W<hex> or $L<hex> is replaced by the row with that id, JSON-decoded if the row is a quoted string. $$… is an escaped literal $…. Anything else is used as is. The value $undefined counts as missing.
  6. Find the notebook body. The body is the first JSON object with a non-empty cells array, searched in this order:
    • an object following "body":{
    • an object starting {"title":"
    • any row that starts with { and contains "cells":[ If none is found it fails with "No Notebooks 2.0 source found on this page. This works on Notebooks 2.0 only — classic notebooks are not supported."

Only the saved notebook is read, so unsaved edits in the editor aren't included.

5. Output file

5.1 Structure

<!doctype html>
<notebook theme="air">
  <title>My notebook</title>
  <script id="1" type="module" pinned="">
    display(1 + 2);
  </script>
  <script id="2" type="text/markdown">
    # Hello
  </script>
</notebook>

5.2 Mode to type

Mode type
js module
ts text/x-typescript
ojs application/vnd.observable.javascript
md text/markdown
html text/html
tex application/x-tex
dot text/vnd.graphviz
sql application/sql
sql.view application/sql+view
node application/vnd.node.javascript
python, py text/x-python
r text/x-r

Any other mode becomes module.

5.3 File name

6. Network calls

7. Result panel

8. Persisted state

None. The tool page and the bookmarklet store nothing in localStorage, cookies or anywhere else.

9. Feedback conventions

Notes & limitations